目次 |
---|
・C#の定数 |
using System; class a{ static void Main(){ const string str = "abc"; Console.WriteLine(str); } }定数のため、宣言後に代入をするとエラーとなります。
using System; class a{ static void Main(){ const string str = "abc"; str = "def"; Console.WriteLine(str); } }上記でコンパイルすると以下のようなエラーがでます。
The left-hand side of an assignment must be a variable,property or indexer