Checking Console.ReadLine()!=null
问题 i am making a CMD for my applcation, and figure i have a trouble when i check Console.ReadLine!=null ---Full Code--- string input = Console.ReadLine(); if(input!=null) { SomeFunction(input); } ---End Of Code--- in SomeFunction() i split this string, so for example: Console.WriteLine(input[0]); so Problem is: It works if user hits enter once. But if use does that again i am getting an exception: That [0] does not exist. 回答1: When you hit ENTER , Console.ReadLine returns empty string . It doesn