日期:2014-05-20 浏览次数:20949 次
object o = GetFromCache("A_KEY"); EmployeeInfo employee = o as EmployeeInfo; if(employee != null) { // TODO: 代码 }
using(SqlDataReader reader = SqlHelper.ExecuteReader(cmd)) { while(reader.read()) { // TODO: 读取当前行的数据 } }
using(SqlDataReader reader = SqlHelper.ExecuteReader(cmd)) { Ilist<EmployeeInfo> list = new List<EmployeeInfo>(); while(reader.read()) { list.add(new EmployeeInfo( reader.getInt32(0) // 其它字段 )); } }
string s = "str1" + "str2" + "str3" + "str4"; // 这段代码不需要使用StringBuilder,因为编译后的代码为 string s = "str1str2str3str4";
public static class ControlExtensions { public static void SendTabKey(this Control control, Keys key) { if (key == Keys.Enter) SendKeys.Send("{TAB}"); } }
------解决方案--------------------
占座
------解决方案--------------------
遍歷control
private void PanelClear(Control c) { foreach (Control cc in c.Controls) { if (cc.GetType() != typeof(Panel)) { PanelClear(cc); } else { ((Panel)cc).Visible = false; } } }
------解决方案--------------------
1)对所有类都重写ToString()方法,这样在调试,绑定中都非常有用。
2)使用Enum代替奇迹数
先说两点。想起来再加。
------解决方案--------------------
找出是否存在某個窗體FORM
for (int j = 0; j < Application.OpenForms.Count; j++) { if (Application.OpenForms[j].Name.Equals("FNO31000")) { fno3100 = true; } } If (fno3100 = true) FNO31000 fno = (FNO31000)Application.OpenForms["FNO31000"]
------解决方案--------------------
插队
------解决方案--------------------
lz写的第4点,用String.Format() 如何?
String.Format("{0}{1}{2}{3}", str0, str1, str2, str3);
------解决方案--------------------
留个名,学习
------解决方案--------------------
將datagridview的某個checkbox不顯示
public void chang_COLOR(int i, string str)//將顯示為N者不顯示選取方塊 { dataGridView1.Rows[i].Cells[str].ReadOnly = true; DataGridViewCell cell = new DataGridViewTextBoxCell(); cell.Style.BackColor = Color.Wheat; //cell.ReadOnly = true; cell.Value = "N"; cell.Style.BackColor = Color.White; dataGridView1.Rows[i].Cells[str] = cell; dataGridView1.Rows[i].Cells[str].Style.ForeColor = Color.White; dataGridView1.Rows[i].Cells[str].Style.SelectionBackColor = Color.White; dataGridView1.Rows[i].Cells[str].Style.SelectionForeColor = Color.White; }