Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

The expression being assigned to '....' must be constant [duplicate]

Tags:

c#

file

constants

What's wrong with this code? I get this error: "The expression being assigned to '....' must be constant"

public const string ConnectionString = System.IO.File.ReadAllText(@"D:\connection.ini"); 
like image 429
Attila Avatar asked Oct 07 '13 10:10

Attila


1 Answers

A constant value must be known at compile time, use readonly instead, it will have a similar effect

like image 56
Steven Wood Avatar answered Oct 05 '22 22:10

Steven Wood