我有一行代码说
string sendQueueName = ESResource.Service.TOPICA.Src();
类的布局方式如下:-
public static class ESResource{
static ESResource() {
//initialization code
}
//other declarations and definitions
public enum Service { TOPICA,TOPICB,TOPICC };
public static string Path(this Service sn) { return FromKey(sn, "PATH"); }
public static string Src(this Service sn) { return FromKey(sn, "SRC"); }
}
我有一个功能要求我能够像这样传递一个字符串环境
string sendQueueName = ESResource.Service.TOPICA.Src(env);
但是当我尝试修改我的 Src 函数以支持上述函数调用时,如下所示:
public static string Src(this Service sn, string env=""){ return FromKey(sn, "PATH", env); }
它说它找不到具有一个参数的函数。传入可选参数 env 的最佳方法是什么?