C#.NET不区分大小写 [英] C#.Net case-insensitive string

查看:467
本文介绍了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 is System.Int32
  • long is System.Int64
  • float is System.Single
  • double is System.Double
  • char is System.Char
  • byte is System.Byte
  • short is System.Int16
  • ushort is System.UInt16
  • uint is System.UInt32
  • ulong is System.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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆