Checking Console.ReadLine()!=null

前端 未结 4 701
执念已碎
执念已碎 2021-01-06 22:51

I am making a CMD for my application, and figure I have a trouble when I check `Console.ReadLine != null``

string input = Console.ReadLine();
 if(input != nu         


        
4条回答
  •  粉色の甜心
    2021-01-06 23:51

    Thanks Every one!

    i figured that i can just check if length of string is 0.

    if(input.Length==0) //(Actually, will check if input.Length !=0 before calling function based on original source)
    

    pretty simple. but

    !string.IsNullOrEmpty(input)
    

    works as well. every day learning something new. thanks for your help!

提交回复
热议问题