Optional parameters “must be a compile-time constant”

后端 未结 8 763
面向向阳花
面向向阳花 2020-12-01 15:42

I have a class divided in two partial files, like this:

public partial class PersonRepository : BaseRepository
{
    public static readonly str         


        
8条回答
  •  孤城傲影
    2020-12-01 16:14

    You must declare your ColumnID as const.

    The static readonly string will be instantiated when the class is first accessed in your code, and you could also initialize it with the return value of a static method, so it's not a compile-time constant for the compiler (even if in this case it obviously is for a person reading the code).

提交回复
热议问题