委托,多播

  1. 多播委托的时候:拿到的返回值是最后一个一个委托指向的方法的执行结果    创建委托:delegate int Adddel(int a,int b);    Adddel del=new Adddel(实例方法名);  不要用了
  2. Func<int,int> funcdemo=new func<int,int>(方法名);  泛型委托 可以最多有16个参数的重载,最后一个参数永远都是返回值  俩个参数一个返回值 

修正:第一个参数标识返回类型,第二个以后的为参数列表

简化泛型匿名方法:Func<int,int,int> funcdemo=delegate(int a ,int b){return a+b;}

继续简化→labmda语句:Func<int,int,int> funcdemo=(int a,int b)=>{return a+b};

继续简化→labmda表达式:Func<int,int,int> funcdemo=(int a,int b)=>a+b;

继续简化→labmda 表达式:Func<int,int,int> funcdemo=(a,b)=>a+b;

微软定义的俩个泛型:Func有返回值   Action无返回值

左侧为要输入的参数,右侧为要求值的表达式或方法体

  1. 读取文件System.IO;

OpenFileDialog ofd=new OpenFileDialog();using

If(ofd.showDialog()!=system.windows.forms.DialogResult.OK){return;}

FilesStream  fs=new FileSteam(ofd.filename,FileModel.Open,FileAccess.Read)using

{

Streamreader sr=new steamreader(fs)

{   while(!st.endofstream)但读取器不为最后一行的时候,否则就跳出循环

{string line=sr.readerline()}

}

保存saveFileDialog sfd=new SaveFileDialog(); 

If(sfd.showDialog()!=system.windows.forms.DialogResult.OK){return;}

Streamwrite sw=new streamwtite(sfd.filename,false,encoding.default,1024*1024);

Sw.write(string);sw.flush();

 

或者

FileSteam fs=new FileSteam(sfd.fileName,filename.openorcrate,fileAccess.readWrete)

{  string txt=要写的字符串.replace(“\n”,”\r\n”); byte[]data=encoding.defalut.getBytes(txt);

Fs.write(data,0,data.length);}

转载于:https://www.cnblogs.com/jinhaoObject/p/4542929.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值