static void Main(string[] args) { int a = 5; int b = 8; mydel <int> md1 = new mydel <int>(swap); Console.WriteLine("Before Swapping {0} {1}", a, b); swap <int>(a, b); String c = "hello"; String d = "bye"; mydel <String> md2 = new mydel <String>(swap); Console.WriteLine("Before Swapping {0} {1}", c, d); swap <String>(c, d); bool f = true; bool g = false; mydel <bool> md3 = new mydel <bool>(swap); Console.WriteLine("Before Swapping {0} {1}", f, g); swap(f, g); Employee e1 = new Employee(10); Employee e2 = new Employee(20); mydel <Employee> md4 = new mydel <Employee>(swap); Console.WriteLine("Before Swapping {0} {1}", e1.a, e2.a); swap <Employee>(e1, e2); }
private void btnLoad_Click_1(object sender, EventArgs e) { SqlCommand com = new SqlCommand("WAITFOR DELAY '00:00:05'; select* from Book", con); com.CommandType = CommandType.Text; com.CommandTimeout = 30; con.Open(); t = new DataTable(); timer1.Start(); label1.Text = "wait...."; SqlDataReader dr = com.ExecuteReader(); for (int i = 0; i < dr.FieldCount; i++) { DataColumn col = new DataColumn(dr.GetName(i), dr.GetType()); t.Columns.Add(col); } mydel del = AddToList; while (dr.Read()) { string row = ""; for (int i = 0; i < dr.FieldCount; i++) { row += dr[i] + " "; } // listBox1.Invoke(del, row); AddToList(row); } label1.Text = "complited..."; timer1.Stop(); progressBar1.Value = progressBar1.Maximum; dr.Close(); con.Close(); }
static void Main(string[] args) { Program p = new Program(); mydel d = p.myfunc; System.Console.WriteLine(d(5)); d = p.myfunc2; System.Console.WriteLine(d(5)); System.Console.Read(); }
public static int[] Map(this int[] ar, mydel mydel1) { for (int i = 0; i < ar.Length; i++) { ar[i] = mydel1(ar[i]); } return(ar); }
static void Main(string[] args) { ClsInfo obj = new ClsInfo(); mydel d1 = new mydel(obj.GetVal); d1(10, 20); Console.Read(); }
static void Main() { mydel del = new mydel(myclass.retInt); del += myclass.retInt1; int z = 10; del(ref z); Console.WriteLine("Value of z " + z); }
static void Main() { sqr obj = new sqr(); mydel objDel1 = new mydel(obj.EnterVal); objDel1 += obj.mult; objDel1 += obj.cub; objDel1(); Console.Read(); }
static void Main(string[] args) { mydel <int> md = new mydel <int>(sqr <int>); md += new mydel <int>(cube <int>); md += new mydel <int>(fact <int>); md(5); }
static void Main(string[] args) { mydel d = (a, b) => a + 2 * b; // in above line, read a,b go to a+b*2 to evaluate System.Console.WriteLine(d(2, 3)); System.Console.Read(); }
static void Main(string[] args) { myevent += new mydel(del); if (myevent != null) { myevent(); } Console.ReadLine(); }
private void upload_completed(IAsyncResult ar) { mydel del = updategui; if (ar.IsCompleted == true) { Invoke(del); } }
static void Main(string[] args) { mydel delg = new mydel(Add); Console.WriteLine(delg(12, 25)); delg += new mydel(Subtract); Console.WriteLine(delg(12, 25)); delg -= new mydel(Subtract); Console.WriteLine(delg(20, 50)); }
static void Main(string[] args) { mydel md = delegate(int a) { sqr(a); cube(a); fact(a); }; md(5); }
static void Main(string[] args) { mydel md = (a) => { sqr(a); cube(a); fact(a); }; md(5); }
static void Main(string[] args) { int ab = 3; mydel a = Program.Function; a += Program.Fun2; System.Console.WriteLine(a(12, ref ab)); System.Console.ReadLine(); }
/// <summary> /// 添加委托 /// </summary> public static void adddelegate() { if (real_s == null) { real_del = real_s.Gv_init; } if (_type_s == null) { _type_dele = _type_s.refresh; } }
static void Main(string[] args) { mydel md = new mydel(add); Console.WriteLine(md(10, 20)); md = md + new mydel(sub); Console.WriteLine(md(2, 3)); mydel1 md1 = new mydel1(square); Console.WriteLine(md1(2)); Console.ReadKey(); }
static void Main(string[] args) { DelegateClass dc = new DelegateClass(); //int number = 2349465; mydel del = dc.printNumber; del += dc.printMoney; del += dc.printHexadecimal; del(10000000); }
static void Menu(mydel x, int first, int second) { ConsoleKeyInfo ItKey = new ConsoleKeyInfo(); do { x(Console.CursorTop); ItKey = Console.ReadKey(); switch (ItKey.Key) { case ConsoleKey.DownArrow: { if (Console.CursorTop >= first) { break; } else { Console.SetCursorPosition(0, Console.CursorTop + 1); } } break; case ConsoleKey.UpArrow: { if (Console.CursorTop <= second) { break; } else { Console.SetCursorPosition(0, Console.CursorTop - 1); } } break; case ConsoleKey.Enter: { } break; default: break; } } while (ItKey.Key != ConsoleKey.Enter); }
static void Main(string[] args) { Random rand = new Random(); mydelegate[] delegateArray = new mydelegate[5]; for (int i = 0; i < delegateArray.Length; i++) { delegateArray[i] = () => rand.Next(0, 1000); } mydel md = delegate(mydelegate[] arr) { int count = 0; for (int i = 0; i < arr.Length; i++) { count += arr[i].Invoke(); Console.WriteLine(count); } return(count / arr.Length); }; Console.WriteLine(md.Invoke(delegateArray)); }
static void Main(string[] args) { Euler.Euler solver = new Euler.Euler(); mydel del = func; double t0 = 0; double y0 = 1; double h = 0.001; double t = 5; int maxIter = 10000; double[] soln = solver.solver(func, t0, y0, h, t, maxIter); foreach (var item in soln) { if (item == 0) { break; } Console.WriteLine(item); } Console.ReadKey(); }
public static void iniform() { try { string state; #region 从本地读取配置信息到内存 string realDisplaySync = RealInterfaceFuction.ReadConfig("RealDisplaySync"); if (realDisplaySync == "1") { OprFuction.ReadRealConfigFromDB();//修改支持多个客户端显示设置同步 20180113 } OprFuction.ReadRealDataDisplayConfig(); OprFuction.ReadDefalutDataConfig(); OprFuction.ReadCustomConfig(); #endregion lock (StaticClass.allPointDtLockObj) { StaticClass.AllPointDt = RealInterfaceFuction.GetAllPoint(); for (int i = 0; i < StaticClass.AllPointDt.Rows.Count; i++) { state = StaticClass.AllPointDt.Rows[i]["zt"].ToString(); if (state == StaticClass.itemStateToClient.EqpState24.ToString() || state == StaticClass.itemStateToClient.EqpState43.ToString()) { StaticClass.AllPointDt.Rows[i]["statecolor"] = StaticClass.AllPointDt.Rows[i]["sszcolor"] = OprFuction.GetShowColor(state, StaticClass.AllPointDt.Rows[i]["0tcolor"].ToString(), StaticClass.AllPointDt.Rows[i]["bj"].ToString()); } else if (state == StaticClass.itemStateToClient.EqpState44.ToString() || state == StaticClass.itemStateToClient.EqpState25.ToString()) { StaticClass.AllPointDt.Rows[i]["statecolor"] = StaticClass.AllPointDt.Rows[i]["sszcolor"] = OprFuction.GetShowColor(state, StaticClass.AllPointDt.Rows[i]["1tcolor"].ToString(), StaticClass.AllPointDt.Rows[i]["bj"].ToString()); } else if (state == StaticClass.itemStateToClient.EqpState26.ToString()) { StaticClass.AllPointDt.Rows[i]["statecolor"] = StaticClass.AllPointDt.Rows[i]["sszcolor"] = OprFuction.GetShowColor(state, StaticClass.AllPointDt.Rows[i]["2tcolor"].ToString(), StaticClass.AllPointDt.Rows[i]["bj"].ToString()); } else { StaticClass.AllPointDt.Rows[i]["statecolor"] = StaticClass.AllPointDt.Rows[i]["sszcolor"] = OprFuction.GetShowColor(state, "0", StaticClass.AllPointDt.Rows[i]["bj"].ToString()); } } } real_s = new RealDisplayForm(); real_s.Dock = DockStyle.Fill; real_del = real_s.Gv_init; _type_s = new DisplayNavagation(); _type_s.Dock = DockStyle.Fill; _type_dele = _type_s.refresh; GetbjThread = new Thread(new ThreadStart(OprFuction.GetbjTh)); GetbjThread.Start(); InitRealWarGridControl(); //Initalarm(); } catch (Exception ex) { OprFuction.SaveErrorLogs(ex.Message, ex); } }
static void Main(string[] args) { myevent += new mydel(del); myevent(); Console.ReadLine(); }
public void RegisterEventDoublefor(mydel f) { this.DoubleFor += f; }
public void RegisterEventOver20(mydel f) { this.Over20 += f; }