标签:
修正:第一个参数标识返回类型,第二个以后的为参数列表
简化泛型匿名方法: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无返回值
左侧为要输入的参数,右侧为要求值的表达式或方法体
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);}
标签:
原文地址:http://www.cnblogs.com/jinhaoObject/p/4542929.html