Optional parameters “must be a compile-time constant”

后端 未结 8 761
面向向阳花
面向向阳花 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:23

    Just for completeness, here are the three valid default values for an optional argument: ( from: MSDN: Named and Optional Arguments)

    1. a constant expression
    2. an expression of the form new ValType(), where ValType is a value type, such as an enum or a struct; (note: only the parameterless constructor can be used)
    3. an expression of the form default(ValType), where ValType is a value type.

提交回复
热议问题