2011年10月18日

c#星期二讲解题

摘要: using System;using System.Collections.Generic;using System.Linq;using System.Text;namespace ConsoleApplication1{ class Program { //要求1+1=? //要求整数+整数=? static void Main(string[] args) { Console.WriteLine(Add(1, 2)); } private static int Add(int a, int b) { return a + b; } }}程序就是把相同的地方提取出来和不同的地方分别提取出. 阅读全文

posted @ 2011-10-18 09:58 叮铛猫 阅读(150) 评论(0) 推荐(1)

C#中ref和out的使用小结

摘要: C#中ref和out的使用小结 ref是传递参数的地址,out是返回值,两者有一定的相同之处,不过也有不同点。 使用ref前必须对变量赋值,out不用。 out的函数会清空变量,即使变量已经赋值也不行,退出函数时所有out引用的变量都要赋值,ref引用的可以修改,也可以不修改。 区别可以参看下面的代码:usingSystem;classTestApp{ staticvoidoutTest(outintx,outinty) {//离开这个函数前,必须对x和y赋值,否则会报错。 //y=x; //上面这行会报错,因为使用了out后,x和y都清空了,需要重新赋值,即使调用函数前赋过值也不... 阅读全文

posted @ 2011-10-18 09:30 叮铛猫 阅读(161) 评论(0) 推荐(0)

C#入门2

摘要: WinForm开发:十五、一个简单的WinForm程序:usingSystem;usingSystem.Drawing;usingSystem.Collections;usingSystem.ComponentModel;usingSystem.Windows.Forms;usingSystem.Data;publicclassSimpleForm:System.Windows.Forms.Form{privateSystem.ComponentModel.Containercomponents=null;privateSystem.Windows.Forms.Buttonbutton1;pr 阅读全文

posted @ 2011-10-18 09:29 叮铛猫 阅读(312) 评论(0) 推荐(0)

C#入门1

摘要: C#入门的一些代码(转载)一2007年01月30日 16:37一、从控制台读取东西代码片断:usingSystem;classTestReadConsole{publicstaticvoidMain(){Console.Write(Enteryourname:);stringstrName=Console.ReadLine();Console.WriteLine(Hi+strName);}}二、读文件代码片断:usingSystem;usingSystem.IO;publicclassTestReadFile{publicstaticvoidMain(String[]args){//Readt 阅读全文

posted @ 2011-10-18 09:19 叮铛猫 阅读(343) 评论(0) 推荐(0)

导航