例如
string[] s = {a,b,c,d}
a,b,c,d分别是string 类的变量,怎么样在更改s[i]的同时,对应的变量也随着被更改?
string[] s = {a,b,c,d}
a,b,c,d分别是string 类的变量,怎么样在更改s[i]的同时,对应的变量也随着被更改?
解决方案 »
- string转decimail类型本机调试不报错,发布后无法添加数据,报错
- C#应该与哪个数据库配合好点?
- 请大家给推荐个好用的浏览器吧
- 如何把dataGridView的某一列数值求合,传递给textBox.Text?
- 传 ref object 和传 object 的区别。
- 为何在XP下能成功调用的C++Dll在windows server 2003下不能调用了?
- 巨难的水印问题,也可以说是印章的问题?
- C# 捕获html中输入框中的值
- 【再次发帖+上传测试Demo】Winform验证问题请教、刨根问底
- 关于datagrid中选择整行的问题
- 关于窗体的切换!
- 求批量上传的控件或源代码,非常急呀!
a="ttt";
就这样改
using System.Data;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Xml.Linq;/// <summary>
///Question 的摘要说明
/// </summary>
public class Question
{
public Question()
{
//
//TODO: 在此处添加构造函数逻辑
//
} /// <summary>
/// dynamic construct fuction
/// </summary>
/// <param name="w">the orm related to database</param>
/// <param name="Subject_U">the table name</param>
/// <param name="ID_U">the identity column</param>
public Question(WebExaminationDataContext w, string Subject_U,int ID_U ,int ID_I)
{
string [] s = {"QTitle","QA","QB","QC","QD","QKey"};
string [] p = {Question_T ,CA ,CB ,CC ,CD ,Key };
for (int i =0;i < s.Length ;i ++)
{
Set_U(w, Subject_U, ID_U, ref p[i], s[i]);
}
ID = ID_I;
} /// <summary>
/// dynamic get this class's property from the database
/// </summary>
/// <param name="w">the orm related to database</param>
/// <param name="Subject_U">the table name</param>
/// <param name="ID_U">the identity column</param>
/// <param name="this_property">the property in this class</param>
/// <param name="selecte_property">the column to be selected in table</param>
protected void Set_U(WebExaminationDataContext w, string Subject_U, int ID_U, ref string this_property, string selecte_property)
{
var query = w.ExecuteQuery<string>("select " + selecte_property + " from " + Subject_U + " where QID = " + ID_U.ToString(), "");
foreach (var q in query)
{
this_property = q.ToString();
}
}
/// <summary>
/// the id num of instanse
/// </summary>
public int ID
{
get;
set;
} /// <summary>
/// the question presentation
/// </summary>
public string Question_T
{
get;
set;
}
/// <summary>
/// the first choose
/// </summary>
public string CA
{
get;
set;
}
public string CB
{
get;
set;
}
public string CC
{
get;
set;
}
public string CD
{
get;
set;
}
/// <summary>
/// the user's answer
/// </summary>
public string U_Key
{
get;
set;
}
/// <summary>
/// the right answer
/// </summary>
public string Key
{
get;
set;
}
public bool IsRight
{
get;
set;
}
/// <summary>
/// check the user's answer is right or wrong
/// </summary>
public void Q_Check()
{
if (U_Key == Key)
IsRight = true;
else
IsRight = false;
}
}