C#数据表作为一个类

C#数据表作为一个类,c#,datatable,C#,Datatable,我需要一个C语言的数据表,可以通过其他方法访问。。。我被告知我需要将datatable作为一个类,而不是一个方法,就像我在下面的示例中所做的那样: //my existing datatable method public DataTable Conditions(){ DataTable dtConditions = new DataTable(); DataColumn firstParameterID = new DataColumn("fir

我需要一个C语言的数据表,可以通过其他方法访问。。。我被告知我需要将datatable作为一个类,而不是一个方法,就像我在下面的示例中所做的那样:

//my existing datatable method     
public DataTable Conditions(){
        DataTable dtConditions = new DataTable(); 

        DataColumn firstParameterID = new DataColumn("firstParameterID ", typeof(int));
        dtConditions.Columns.Add(firstParameterID);

        DataColumn secondParameterID = new DataColumn("secondParameterID ", typeof(int));
        dtConditions.Columns.Add(secondParameterID ); 
         /*
         * more columns and rows...
         */
        return dtConditions;
    }
我的问题是:我该如何将其放入一个名为dataTableConditions.cs的单独类文件中

我创建了一个类文件,下面是我所拥有的,但是接下来呢

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Data;

namespace myHomeworkProject
{
    class dataTableConditions
    {
        //How do I make this class and later how can I access its rows, I mean, how can I assign values to these rows later from other methods?
    }
}

谢谢大家!

因为您正在创建以下内容

 DataTable dtConditions = new DataTable(); 
您应该创建一个
DataTable
类。该类可以如下所示:

使用System.Collections.Generic;
名称空间名称空间{
公共类数据表{
公共列表列{get;set;}
}

}
你的意思是作为类属性吗?我猜你被告知有另一个类存储你的
数据表
方法。这是我第一次听说DataTable是一个类,请原谅我的无知,因为我是初学者:)谢谢