Type-inferring a constant in C#

后端 未结 11 1174
花落未央
花落未央 2020-12-05 13:14

In C#, the following type-inference works:

var s = \"abcd\";

But why can\'t the type be inferred when the variable is a constant?

T

11条回答
  •  忘掉有多难
    2020-12-05 13:36

    I agree with Eric that this is ugly as sin:

    const var s = "abcd"

    But why not simply this?

    const s = "abcd"

    Seems like a reasonable syntax to me.

提交回复
热议问题