2009年9月26日

摘要: foreach语法结构,是C#中新增的循环机制,可以迭代集合中的每一项示例:using System;using System.Collections.Generic;using System.Linq;using System.Text;namespace Demo8{ class Program { static void Main(string[] args) { Program pro =... 阅读全文

posted @ 2009-09-26 12:39 Relax Active 阅读(1565) 评论(0) 推荐(0)

摘要: goto 语句用法:1.goto 语句可以直接跳转到程序中另一行代码的语句;2.goto语句不能跳转到for循环的语句;3.goto语句不能跳出类的范围4.goto语句不能退出try…catch后面的finally块using System;using System.Collections.Generic;using System.Linq;using System.Text;name... 阅读全文

posted @ 2009-09-26 12:38 Relax Active 阅读(485) 评论(0) 推荐(0)

摘要: 学过C和C++朋友应该对switch…case语句很熟悉,这里讨论他们的不同之处。1. C#的switch…case语句比其它语言更安全;2.C#禁止所有case的失败条件;3.C#支持goto语句,可使用goto语句激活后面的case子句;4.C#中的case子句可任意排序;5.C#中可以把字符串用做测式变量!代码示例:using System;using System.... 阅读全文

posted @ 2009-09-26 12:38 Relax Active 阅读(263) 评论(0) 推荐(0)

摘要: (1)string类型string类型表示 Unicode 字符的字符串。string是 .NET Framework 中的string的别名。字符串是不可变的。字符串对象一旦被创建,其内容就不能更改。String类型特征:1.它是引用类型,在堆上分配内存2.运算时会产生一个新的实例3.String 对象一旦生成不可改变(Immutable)尽管string是引用类型,但定义相等运算符(== 和 ... 阅读全文

posted @ 2009-09-26 12:37 Relax Active 阅读(452) 评论(0) 推荐(0)

摘要: (1) 预定义类型C#提供了与C/C++类似的一系列预定义类型,包括整型(包括符号数、无符号数)、浮点类型、布尔类型、字符类型和十进制类型。整型有:sbyte、short、 int和long(符号数),byte、ushort、uint和ulong(无符号数);浮点数有:float和double; 布尔类型有:true或false。c#对布尔的要求比c/c++严格,与java类似。在c#中false... 阅读全文

posted @ 2009-09-26 12:36 Relax Active 阅读(329) 评论(0) 推荐(0)

摘要: 静态类的主要特征:1、它们仅包含静态成员,而且不能用protected或protected internal访问保护修饰符2、它们不能被实例化3、它们不能被继承4、它们是密封的、相当于一个sealed abstract类。 5、它们不能包含实例构造函数。静态成员特征:a、属于类,不属于对象b、包含静态成员变量(字段、属性)和 静态方法(静态构造函数)c、即使没有创建类的实例,也可以调用该类中的静态... 阅读全文

posted @ 2009-09-26 12:36 Relax Active 阅读(303) 评论(0) 推荐(0)

摘要: (1)变量的作用域using System;using System.Collections.Generic;using System.Linq;using System.Text;namespace Demo3{ class Program { static void Main(string[] args) { for(int i = 0; i < 10; i++) { Console.W... 阅读全文

posted @ 2009-09-26 12:35 Relax Active 阅读(745) 评论(0) 推荐(0)

摘要: 示例代码:using System;using System.Collections.Generic;using System.Linq;using System.Text;namespace Demo2{ class Program { static void Main(string[] args) { int a ; Console.WriteLine(a); } }}错误 1 使用了未赋值的... 阅读全文

posted @ 2009-09-26 12:34 Relax Active 阅读(271) 评论(0) 推荐(0)

摘要: 示例代码:using System;using System.Collections.Generic;using System.Linq;using System.Text;namespace Demo1{ class Program { static int a = 2;//声明int型字段变量a,并初始化它的值 static string b = "I love asp.net!";//声明s... 阅读全文

posted @ 2009-09-26 12:33 Relax Active 阅读(177) 评论(0) 推荐(0)

摘要: 这是我学习C#的笔记,初学C#难免有些不理解的地方,如有不对地方请指正,谢谢! 阅读全文

posted @ 2009-09-26 12:31 Relax Active 阅读(154) 评论(1) 推荐(1)


博客园  ©  2004-2025
浙公网安备 33010602011771号 浙ICP备2021040463号-3

点击右上角即可分享
微信分享提示