请高手看这种用法应该怎么写!谢谢
public class table_info2
{
public string col_name; //列名
public object data;
public bool edit_allow;
public Type data_type;
public table_info2(string col_name, object data, bool edit_allow)
{
this.col_name = col_name;
this.data = data;
this.edit_allow = edit_allow;
this.data_type = data.GetType();
}
}
private List<table_info2> get_para_table22(ref TestItem test_item)
{
object ddd = test_item;
List<table_info2> para_table = new List<table_info2>
(new table_info2[]
{
new table_info2("Execute", test_item.exe_flag,true),
new table_info2("Script Path", test_item.script_path,true),
new table_info2("Software Info", test_item.sw_info,true),
new table_info2("Hardware Info", test_item.hw_info,true),
new table_info2("Frequency Range", test_item.frq_range,true)
}
);
//para_table[3].data = sfsdfs"";s
return para_table;
}
=================================================
// 在调用的地方
// test_item 已经有值了
var para_table = get_para_table22(ref test_item);
object data = para_table[row].data;
para_table[row].data = value;
我的目的就是想当给 para_table[row].data 赋值时,对应的test_item的相应属性也能跟着变化。
比如 para_table[1].data = false,那么 test_item.exe_flag 也会被改为false;
para_table[2].data = "sfdsfsfs",那么 test_item.script_path值也为 "sfdsfsfs";
像达到C里的指针那样的效果;但这样写虽 para_table[row].data 赋值了,但test_item的对应值没有变化;
刚从C转战到C#,很多用法不知怎么写!
请高手看下为了达到这个效果应该怎么写好?先谢了