ふらっと C#,C♯,C#(初心者用) Part160at TECH
ふらっと C#,C♯,C#(初心者用) Part160 - 暇つぶし2ch12:デフォルトの名無しさん (ワッチョイ e31e-XyAm)
24/02/15 20:50:19.72 TvfAuxJO0.net
C#コンパイラチーム開発者の回答
URLリンク(stackoverflow.com)

> > why can't the type be inferred when the variable is a constant?
>
> "constant" and "variable" are opposites. const var gives me the shudders to type.
> A constant is a value that never changes and has no storage location; a variable is a storage location whose contents change.
> They're completely different, so don't attempt to combine them.
> The var syntax was chosen to call out "this is a variable", and we're sticking with it.
>
> var can stand in for a specific type declaration, but combining it with const severely muddies the picture of what the compiler does with the value.
> Therefore const var is disallowed to prevent this confusion and you have to explicitly type your constants.


次ページ
続きを表示
1を表示
最新レス表示
レスジャンプ
類似スレ一覧
スレッドの検索
話題のニュース
おまかせリスト
オプション
しおりを挟む
スレッドに書込
スレッドの一覧
暇つぶし2ch