【问题标题】:What is the difference Between String and string? [duplicate]字符串和字符串有什么区别? [复制]
【发布时间】:2011-02-26 00:11:08
【问题描述】:

可能重复:
String vs string in C#

String 和 string 或 Double 和 double 有什么区别?

如果我使用:

双 s1;或

如果我使用 Double s1;

你能说出优点和缺点吗?

【问题讨论】:

    标签: c# .net visual-studio oop


    【解决方案1】:

    string 只是 System.String 类的 C# 别名。对于所有其他内置语言类型也是如此,例如:

    • int (System.Int32)
    • 浮动(System.Single)
    • 双 (System.Double)
    • 十进制(System.Decimal)
    • bool (System.Boolean)
    • 等等……

    就使用约定而言,我完全同意this answer on SO

    相关资源:

    【讨论】:

    • doubleSystem.Double 的别名。
    【解决方案2】:

    stringSystem.String 的别名。使用Stringstring 都没有关系。最后还是翻译成System.String

    System.Int32int 等情况相同。

    Here 是所有别名的列表。

    【讨论】:

      【解决方案3】:

      string 或 String 是 System.String 的 CLR 别名

      【讨论】:

        【解决方案4】:

        见:string (Référence C#)

        根据 MSDN :

        字符串类型表示零个或多个 Unicode 字符的序列。 string 是 .NET Framework 中 String 的别名。

        简而言之,没有区别,因为一个是另一个的糖语法。

        【讨论】:

        • 你链接到法语版的 MSDN :P
        • 感谢您的提及! =) 我更改了英文链接。
        猜你喜欢
        • 2011-09-05
        • 2018-11-12
        • 1970-01-01
        • 2010-09-13
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多