不带参数的跨线程
{
{
}); t.Start(); } |
注意:Invoke应用在其他线程内部;
带参数的跨线程
{
}
{
} |
不带参数的跨线程
{
{
}); t.Start(); } |
注意:Invoke应用在其他线程内部;
带参数的跨线程
{
}
{
} |
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms;
namespace WindowsFormsApplication2 {
{
{ InitializeComponent();
f2.ShowCounter = new f2.Show(); }
{
} } }
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms;
namespace WindowsFormsApplication2 {
{
{ InitializeComponent(); }
{ counter++; ShowCounter?.Invoke(counter); } } } |
xml文件内容
<?xml version=”1.0″ encoding=”utf-8″ standalone=”yes”?> <library> <book> <name>笑傲江湖</name> <name1>罪与罚</name1> </book> </library> |
文件的读取
{
op.Filter = “xml文件|*.xml”; op.ShowDialog();
} |
文件的写入
{
op.Filter = “xml文件|*.xml”; op.ShowDialog();
name1.Value = “笑傲江湖“; name2.Value = “罪与罚“; document.Save(op.FileName); } |
你有没有想过像调用变量一样调用函数,把函数当做变量一样传递。
定义委托
delegate |
仔细看一下上面的定义,会发现这很像一个函数。
下面演示一下委托的简单的应用。
using System;
namespace ConsoleApplication3 {
{
{
}
{
} } } |
下面的例子演示函数作为变量传递
using System;
namespace ConsoleApplication3 {
{
{
Wsum(f,1,2); Wsum(Add,1,2); }
{
}
{
} } } |
2021年11月5日