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

后端 未结 9 2457
太阳男子
太阳男子 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:23

    Just to make Eric Lipperts comment visible:

    Features have to be justified on a cost-benefit basis. What's the benefit that justifies the cost? If there's no benefit that justifies the cost then it should be illegal simply on the economic grounds that we have better things to do than to design, specify, implement, test, document and maintain a constructor that no one uses or needs.

提交回复
热议问题