我正在尝试为应用程序创建自己的设置(Properties.Settings不能按照我需要的方式工作)我创建了tis:
通用课程设置:
public abstract class AppSettingsPropertie
{ }
class AppSettingsPropertie<T> : AppSettingsPropertie where T : struct
{
public AppSettingsPropertie(string name, T value)
{
Name = name;
Value = value;
}
public string Name { get; private set; }
public T Value { get; set; }
}
我需要的地方:
List<AppSettingsPropertie> Properties;
Properties = new List<AppSettingsPropertie>();
Properties.Add(new AppSettingsPropertie<string>("hello", "test"));
VS告诉我它不能使用字符串因为它没有得到值而且为空
答案 0 :(得分:0)
删除where T:struct限制,代码将编译。 - 糊状 它的工作原理