C#コンパイラチーム開発者の回答
https://stackoverflow.com/questions/2128432/type-inferring-a-constant-in-c-sharp#answer-2128581
> > 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.
探検
ふらっと C#,C♯,C#(初心者用) Part160
■ このスレッドは過去ログ倉庫に格納されています
12デフォルトの名無しさん (ワッチョイ e31e-XyAm)
2024/02/15(木) 20:50:19.72ID:TvfAuxJO0■ このスレッドは過去ログ倉庫に格納されています
ニュース
- 【地震速報】青森県で震度6強 沿岸部に津波警報 ★6 [ぐれ★]
- 「日の丸にバツ印」掲げた大学生 あいまいな国旗損壊罪に「怖い」 The Mainichi [少考さん★]
- 高市内閣「支持」64%「不支持」19% NHK世論調査 ★2 [少考さん★]
- 【音楽】BARBEE BOYS・KONTAが事故で四肢麻痺を公表、新体制で活動は継続 [少考さん★]
- 高市首相「多様なコメの増産を進める」 方針転換への懸念払拭狙いか ★2 [どどん★]
- 中国「捜索レーダー起動は各国の通常の手法」 火器管制用か回答せず [蚤の市★]
- 初めて顔パックしたけど凄いなこれ
- ぺこーら、地震で同僚が次々配信を止めるなか強行し続けるので悪目立ちするwww [268244553]
- 巨大地震 [957955821]
- 千晴の住所教えてよ!
- 【🏡】岩手ビックウェーブ🏄うおおおおおおおおおおお🌊
- 【速報】高市早苗、起床 [779938112]
