zoukankan      html  css  js  c++  java
  • C# String与string的区别

    C#中同时存在String与string

    MSDN中对string的说明:

    string is an alias for String in the .NET Framework。string是String的别名而已,string是c#中的类,String是Framework的类,C# string 映射为 Framework的 String。如果用string,编译器会把它编译成String,所以如果直接用String就可以让编译器少做一点点工作。

    如果使用C#,建议使用string,比较符合规范 。 string始终代表 System.String(1.x) 或 ::System.String(2.0) ,String只有在前面有using System;的时候并且当前命名空间中没有名为String的类型(class、struct、delegate、enum)的时候才代表System.String。

        • string是c#中的类,String是.net Framework的类(在c# IDE中不会显示蓝色)

        • c# string映射为.net Framework的String

        • 如果用string,编译器会把它编译成String,所以如果直接用String就可以让编译器少做一点点工作

        • 如果使用c#,建议使用string,比较符合规范

        • string始终代表 System.String(1.x) 或 ::System.String(2.0) ,String只有在前面有using System;的时候并且当前命名空间中没有名为String的类型(class、struct、delegate、enum)的时候才代表System.String

        • string是关键字,String不是,也就是说string不能作为类、结构、枚举、字段、变量、方法、属性的名称,而String可以

  • 相关阅读:
    5860. 从双倍数组中还原原数组
    5847. 找到所有的农场组
    5846. 找到数组的中间位置
    442. 数组中重复的数据
    1987. 不同的好子序列数目
    1986. 完成任务的最少工作时间段
    1985. 找出数组中的第 K 大整数
    1984. 学生分数的最小差值
    学习内容整合
    spring-DI和spring-mybatis整合
  • 原文地址:https://www.cnblogs.com/albertly/p/1335823.html
Copyright © 2011-2022 走看看