码迷,mamicode.com
首页 > Windows程序 > 详细

C# ignoring letter case for if statement(Stackoverflow)

时间:2015-03-21 22:46:49      阅读:216      评论:0      收藏:0      [点我收藏+]

标签:

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") { }

C# ignoring letter case for if statement(Stackoverflow)

标签:

原文地址:http://www.cnblogs.com/wuyux/p/4356363.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!