IAb*_*act 2 c# extension-methods
我有:
public static class DataManager
{
private static Dictionary<string, DataTable> dataTables;
// extension method
public static DataTable GetTable ( this string TableName )
{
return dataTables[ TableName ];
}
}
Run Code Online (Sandbox Code Playgroud)
我不想公开Dictionary集合,这是我想完成这个任务的方式.在我的调用方法中:
DataTable GetTable (string TableName)
{
return TableName.GetTable();
}
Run Code Online (Sandbox Code Playgroud)
我还有另一种方式,或者可以这样做吗?或者这可以接受吗?