C#.NET不区分大小写 [英] C#.Net case-insensitive string
本文介绍了C#.NET不区分大小写的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
为什么C#.NET允许字符串对象的声明是不区分大小写?
Why does C#.Net allow the declaration of the string object to be case-insensitive?
String sHello = "Hello";
string sHello = "Hello";
两个小写和大写S中的单词串的是可以接受的,这似乎是,它允许此的唯一对象。
Both the lower-case and upper-case S of the word String are acceptable and this seems to be the only object that allows this.
任何人都可以解释为什么?
Can anyone explain why?
推荐答案
字符串
是一种语言的关键字,而系统.String
是它的别名类型。
这两种编译为同样的事情,同样的:
Both compile to exactly the same thing, similarly:
-
INT
是System.Int32的
-
长
是System.Int64
-
浮动
是System.Single
-
双
是System.Double
-
字符
是System.Char
-
字节
是System.Byte
-
短
是System.Int16
-
USHORT
是System.UInt16形式
-
UINT
是System.UInt32
-
ULONG
是System.UInt64形式
int
isSystem.Int32
long
isSystem.Int64
float
isSystem.Single
double
isSystem.Double
char
isSystem.Char
byte
isSystem.Byte
short
isSystem.Int16
ushort
isSystem.UInt16
uint
isSystem.UInt32
ulong
isSystem.UInt64
我认为在大多数情况下,这大约是code易读性 - 所有的基本制度价值类型有别名,我觉得小写字符串
可能只是一致性
I think in most cases this is about code legibility - all the basic system value types have aliases, I think the lower case string
might just be for consistency.
这篇关于C#.NET不区分大小写的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文