相关疑难解决方法(0)

可选参数"必须是编译时常量"

我有一个分为两个部分文件的类,如下所示:

public partial class PersonRepository : BaseRepository<Person>
{
    public static readonly string ColumnID = "ID";
    ...
Run Code Online (Sandbox Code Playgroud)

public partial class PersonRepository : BaseRepository<Person>
{
    public List<Person> GetByCompany(int companyID, string sortExpression = ColumnID)
    {
    ...
Run Code Online (Sandbox Code Playgroud)

但编译器一直说sortExpression"必须是编译时常量".对我来说,这似乎是一个完美的编译时常量,所以我不明白问题出在哪里.

.net c#

47
推荐指数
5
解决办法
4万
查看次数

标签 统计

.net ×1

c# ×1