C#.Net不区分大小写的字符串

栏目: ASP.NET · 发布时间: 6年前

内容简介:翻译自:https://stackoverflow.com/questions/9734/c-net-case-insensitive-string

为什么C#.Net允许字符串对象的声明不区分大小写?

String sHello = "Hello";
string sHello = "Hello";

单词String的小写S和大写S都是可接受的,这似乎是允许这个的唯一对象.

有人可以解释为什么吗

string是一个语言关键字,而System.String是它别名的类型.

两者编译成完全相同的东西,类似:

> int是System.Int32

> long是System.Int64

> float是System.Single

> double是System.Double

> char是System.Char

> byte是System.Byte

>简称是System.Int16

> ushort是System.UInt16

> uint是System.UInt32

> ulong是System.UInt64

我认为在大多数情况下,这是关于代码易读性 – 所有基本系统值类型都有别名,我认为小写字符串可能只是为了一致性.

翻译自:https://stackoverflow.com/questions/9734/c-net-case-insensitive-string


以上所述就是小编给大家介绍的《C#.Net不区分大小写的字符串》,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对 码农网 的支持!

查看所有标签

猜你喜欢:

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们

Deep Learning

Deep Learning

Ian Goodfellow、Yoshua Bengio、Aaron Courville / The MIT Press / 2016-11-11 / USD 72.00

"Written by three experts in the field, Deep Learning is the only comprehensive book on the subject." -- Elon Musk, co-chair of OpenAI; co-founder and CEO of Tesla and SpaceX Deep learning is a for......一起来看看 《Deep Learning》 这本书的介绍吧!

在线进制转换器
在线进制转换器

各进制数互转换器

Markdown 在线编辑器
Markdown 在线编辑器

Markdown 在线编辑器

HSV CMYK 转换工具
HSV CMYK 转换工具

HSV CMYK互换工具