我有下面的代码,它应该要求用户输入由#(如1#2#3##2等)分隔的各种整数。然后应该找到输入序列中具有重复的值并将其显示为“序列包含 2 个重复值”。
但是,我不确定用于分隔用户输入值的代码是否正确,因为它显示错误:
public class Program
{
public static void Main(string[] args)
{
// Keep the following line intact
Console.WriteLine("===========================");
// Insert your solution here.
// user input gets the input from the user
// regarding a line where integers are separated by #
String userInput;
Console.WriteLine("Please enter single line containing a list of integers, separated by '#':");
userInput = Console.ReadLine();
// splitting the userInput into Array of Strings
if (userInput != null)
{
// …Run Code Online (Sandbox Code Playgroud) c# ×1