CS0649 私有静态字段警告
CS0649 warning on private static field
我收到以下警告:
Warning CS0649 Field 'TemplateManager.Templates' is never assigned to,
and will always have its default value null
相关代码如下:
public static class TemplateManager
{
private static Dictionary<string, Stream> Templates;
public static List<string> TemplateNames { get; private set; }
static TemplateManager()
{
Templates = new Dictionary<string, Stream>();
TemplateNames = new List<string>();
}
我好像在给它赋值。这是一个错误还是我只是遗漏了一些重要的东西?是否与classand/or字段是静态的有关?
这可能是因为你设置了私密。这可能意味着您无法访问 set 函数,因此它永远不会从 null 更新。去掉private before set试试看
[更新]
是的,我的错,我完全误读了。
问题已通过清理和重建我的项目得到解决。
我收到以下警告:
Warning CS0649 Field 'TemplateManager.Templates' is never assigned to, and will always have its default value null
相关代码如下:
public static class TemplateManager
{
private static Dictionary<string, Stream> Templates;
public static List<string> TemplateNames { get; private set; }
static TemplateManager()
{
Templates = new Dictionary<string, Stream>();
TemplateNames = new List<string>();
}
我好像在给它赋值。这是一个错误还是我只是遗漏了一些重要的东西?是否与classand/or字段是静态的有关?
这可能是因为你设置了私密。这可能意味着您无法访问 set 函数,因此它永远不会从 null 更新。去掉private before set试试看
[更新] 是的,我的错,我完全误读了。
问题已通过清理和重建我的项目得到解决。