这是我的代码。只是写一个简单的程序来练习字符串和使用它的方法。我无论如何都不能让控制台读取我想要存储在变量"myNameFirst"中的"Console.ReadLine()"。
我已经重新启动了计算机,重新安装了Visual Studio,确保没有拼写错误。我还搜索了其他的问题,但似乎没有人知道如何修复控制台跳过行的问题。
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Please enter a string here and press enter.");
string user = Console.ReadLine();
Console.WriteLine("Now enter a character to search for:");
char userChar = (char)Console.Read();
Console.WriteLine($"The index of the letter {userChar} is {user.IndexOf(userChar)}");
Console.WriteLine("What is your first name?");
string myNameFirst= Console.ReadLine();
Console.WriteLine(myNameFirst);
}
}
}
我已经重新启动了计算机,重新安装了Visual Studio,确保没有拼写错误。我还搜索了其他的问题,但似乎没有人知道如何修复控制台跳过行的问题。