Why is new String(“Hello”) invalid in C#?

后端 未结 9 2664
太阳男子
太阳男子 2021-02-19 03:41

What is the logic/reason behind making

String s= new String(\"Hello World\");

Illegal in C#? The error is

The best over

9条回答
  •  没有蜡笔的小新
    2021-02-19 04:27

    The constructor you are trying to use takes in...

    A pointer to a null terminated array of Unicode characters

    ...rather than a String.

    (See http://msdn.microsoft.com/en-us/library/aa331864(v=VS.71).aspx)

提交回复
热议问题