我建立了一个Subjects的数据表,含有 “英语","操作系统","日语","软件工程概论","Java","体育",共6列,
然后我在网页的Page_Load中创建了一个数组
string[] subject = new string[6]{"英语","操作系统","日语","软件工程概论","Java","体育"};,
然后我就用这个数组中的成员访问数据,比如想遍历”英语“这一列,用Subjects.subject[0]
却显示CS1061: “Subjects”不包含“subject”的定义,并且找不到可接受类型为“Subjects”的第一个参数的扩展方法“subject”(是否缺少 using 指令或程序集引用?)
。。。。。。。。。但是用 "Subjects.英语" 就可以访问,没有错误,,,,请高手帮帮小弟,非常紧急。。。。。。。。。。。。。。谢谢诶 ,该怎么解决啊 ,就是想用数组,在AOD.NET有ROw【】,
是不是要先实例化怎么实例啊,问题解决一定给分,代码:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class Students_Subjects : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
string[] subject = new Subject[6]{"英语","日语","操作系统","软件工程概论","java","体育"};
using (SBDataContext myDataContext = new SBDataContext())
{
var element = from student in myDataContext.Subjects
select student;
foreach (var student in element)
{
for (int i = 0; i <= 6; i++)
{
Subjects.subject[i]="未选";//但是用Subjects.英语,就可以
}
}
}
}
}