【发布时间】:2014-01-08 07:44:36
【问题描述】:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections.Specialized;
using System.Configuration;
我收到此错误
cannot declare instance members in a static class
在编写静态类时。 如果可能的话,知道如何解决它保持类静态吗?谢谢
namespace XXX.Helpers
{
public static class Utility
{
public static string GetConfiguration(string section, string key)
{
NameValueCollection mySection = (NameValueCollection)ConfigurationManager.GetSection(section);
return mySection[key];
}
}
}
【问题讨论】:
-
实例成员在哪里?
-
我尝试使用您的代码,但它没有给我任何错误..
-
我在提供代码中没有看到任何错误