C# ignoring letter case for if statement(*)

Question:

I have this if statement:

if (input == 'day')
Console.Write({0}, dayData);

When the user types 'day' it should be so that the console writes the data in that array. It works fine but is there anyway to get it to work if the user types 'DaY' or 'dAy' etc. I know I could do:

if (input == 'day' || input == 'dAy' || input == 'DaY')
Console.WriteLine({0}, dayData);

But is there anyway to make it shorter and tidier?

Thanks.

Answer:

if (input.ToLower() == "day") { }
上一篇:5.Struts.xml标签中的一些小技巧


下一篇:a 标签中加 onclick事件,根据事件中的校验情况来决定是否执行a标签的链接