Why is “string” considered a simplified version of “String”?

前端 未结 4 1821

In C# I usually use String when I\'m utilizing a method and string when declaring a variable. I read elsewhere that this is the preferred method to

4条回答
  •  既然无缘
    2020-12-03 07:12

    string is an alias in C# for System.String. So technically, there is no difference. It's kinda like int vs. System.Int32.

    As far as the what you 'Should' do, string is the preferred object for variables and String for classes as it the practised choice.

    usually seen like this

    string example = "hello world";
    
    string example = String.Format("Hello World {0}!", example);
    

提交回复
热议问题