C# 不能调用类变量

C# 不能调用类变量,c#,C#,我有一门课叫ChartEx public class ChartEx { public string name { get; set; } public List<int> data { get; set; } } 公共类ChartEx { 公共字符串名称{get;set;} 公共列表数据{get;set;} } 我正试图从我的代码后面调用它 List<int> lstXaxis = new List<int>() { 9, 10, 11

我有一门课叫ChartEx

 public class ChartEx
{
    public string name { get; set; }
    public List<int> data { get; set; }
}
公共类ChartEx
{
公共字符串名称{get;set;}
公共列表数据{get;set;}
}
我正试图从我的代码后面调用它

List<int> lstXaxis = new List<int>() { 9, 10, 11, 12 };
List<ChartEx> lstseries = new List<ChartEx>();
List lstXaxis=newlist(){9,10,11,12};
List lstseries=新列表();

它能够识别
List lstXaxis=new List(){9,10,11,12}但在
列表lstseries=new List()上显示错误

尝试使用namespace.ChartEx,其中namespace是类所在的appcode文件名称空间

你犯了什么错误?您正在尝试在静态方法中初始化非静态变量吗?这是asp.net还是winforms?请显示代码的完整上下文。我粘贴您的代码。没问题@无论是ASP.NET还是Windows窗体,Icarus都应该是无关紧要的。从语法上讲,代码是正确的,所以错误是另外一回事。您使用的是WinForms吗?