我发现以下对我有用的 C# 代码:
public partial class Default2 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (Session["EID"] != null)
{
int EmpID = (int)Session["EID"];
DataClassesDataContext dc = new DataClassesDataContext();
var empInfo = from emp in dc.EmployeeLogins
where emp.EmployeeID == EmpID
select new
{
emp.EmployeeLoginKey,
emp.EmployeeID,
emp.username,
emp.passwd
};
foreach (var v in empInfo)
{
lblID.Text = v.EmployeeID.ToString();
lblLoginKey.Text = v.EmployeeLoginKey.ToString();
lblPassword.Text = v.passwd.ToString();
lblUserName.Text = v.username.ToString();
}
}
else
{
Response.Redirect("Default.aspx");
}
}
}
之前用在线转换器转成vb,编译程序的时候报错如下一句:
For Each v As var In empInfo
如何将var从c#转换为vb?