学无止境

Life-long learning
  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

随笔分类 -  学习--C# 面向对象程序设计

如何一步一步来学习C# 面向对象程序设计~~~
摘要:首页 博客 技术文章 C#语言 数据模式 源码发布 .NET控件库 ... 阅读全文

posted @ 2008-08-04 18:16 anytime8 阅读(450) 评论(1) 推荐(1)

摘要:using System; class Account { private double balance = 0; //字段 public double Balance //属性 { get { return balance; } set { balance = value;} } /*============================================... 阅读全文

posted @ 2008-08-04 18:10 anytime8 阅读(233) 评论(0) 推荐(0)

摘要:using System; class Base { /* * public 的可访问范围是所有类 * private 的可访问范围是当前类 * protected 的可访问范围是当前类及其子类 */ public string name = "Tom"; private double salary = 1500; protected int age = 20; publ... 阅读全文

posted @ 2008-08-04 18:09 anytime8 阅读(205) 评论(0) 推荐(0)

摘要:using System; class SumToHundred { public static void Main() { int sum=0; for(int i=1; i<=100; i++) sum += i; Console.WriteLine(sum); } } 阅读全文

posted @ 2008-08-04 18:09 anytime8 阅读(157) 评论(0) 推荐(0)

摘要:using System; using System.Collections; public enum enuSortOrder {IDAsc, IDDesc, RankAsc, RankDesc} public class Person : IComparable { public static enuSortOrder intSortOrder = enuSortOrder.IDAsc; ... 阅读全文

posted @ 2008-08-04 18:08 anytime8 阅读(215) 评论(0) 推荐(0)

摘要:using System; using System.Collections; public class Person : IComparable { public int ID; public string Rank; public Person(int id, string rank) { this.ID=id; this.Rank = rank; } #region ICompa... 阅读全文

posted @ 2008-08-04 18:07 anytime8 阅读(179) 评论(0) 推荐(0)

摘要:using System; class ArraySort { public static void Main() { int[] d = {10,15,21,43,17,98,2,74,63,10}; int temp; //冒泡法排序 for(int i=0; i<d.Length; i++) for(int j=i+1; j<d.Length; j++) ... 阅读全文

posted @ 2008-08-04 18:06 anytime8 阅读(237) 评论(0) 推荐(0)

摘要:using System; class Factor { public static void Main() { for(int i=1; i<=100; i++) if(IsPrime(i)) Console.WriteLine(i); } public static bool IsPrime(int n) { for(int i=2; i... 阅读全文

posted @ 2008-08-04 18:06 anytime8 阅读(153) 评论(0) 推荐(0)

摘要:using System; class ArraySort { public static void Main() { int[] d = {10,15,21,43,17,98,2,74,63,10}; int temp; //冒泡法排序 for(int i=0; i<d.Length; i++) for(int j=i+1; j<d.Length; j++) ... 阅读全文

posted @ 2008-08-04 18:04 anytime8 阅读(613) 评论(0) 推荐(0)

摘要:using System; public class JiuJiuBiao { public static void Main(string[] args) { int i,j; for(i=1; i<10; i++) { for(j=1; j<10; j++) { Console.Write("{0:D1}*{1:D1}={2,2} ", i, j, i*j... 阅读全文

posted @ 2008-08-04 18:04 anytime8 阅读(336) 评论(0) 推荐(0)

摘要:using System; class StaticHello { public static void SayHello() { Console.WriteLine("Static Hello"); } } class NonStaticHello { public void SayHello() { Console.WriteLine("Non Static Hello"); } } ... 阅读全文

posted @ 2008-08-04 18:03 anytime8 阅读(187) 评论(0) 推荐(0)

摘要:using System; public class Person { public string name = ""; public int age = 0; //默认构造函数 public Person() { } //构造函数重载(1) public Person(int Age) { this.age = Age; } //构造函数重载(2) public Pe... 阅读全文

posted @ 2008-08-04 18:02 anytime8 阅读(189) 评论(0) 推荐(0)

摘要:using System; class Client { public static void Main() { //重载是指方法名相同,方法的签名不同 Console.WriteLine(Add(10,5)); Console.WriteLine(Add("10","5")); } public static string Add(string a, string b) ... 阅读全文

posted @ 2008-08-04 17:55 anytime8 阅读(198) 评论(0) 推荐(0)

摘要:using System; class Car { public virtual void Drive() { Console.WriteLine("Drive Car"); } } class Truck : Car { public override void Drive() { Console.WriteLine("Drive Truck"); } } class Client { ... 阅读全文

posted @ 2008-08-04 17:54 anytime8 阅读(186) 评论(0) 推荐(0)

摘要:using System; class Factor { public static void Main() { for(int i=1; i<=10; i++) Console.WriteLine("{0} 的阶乘是 {1}",i, Factorial(i)); } public static long Factorial(long n) { if(n == 1) ... 阅读全文

posted @ 2008-08-04 17:51 anytime8 阅读(619) 评论(0) 推荐(0)

摘要:using System; public class Hello { public static void Main() { Console.Write("请输入行数:"); int lines = int.Parse(Console.ReadLine()); Console.WriteLine(""); for(int i=1; i<=lines ; i++) { ... 阅读全文

posted @ 2008-08-04 17:50 anytime8 阅读(166) 评论(0) 推荐(0)

摘要:using System; class MethodCall { public static void Main() { /* * 参数类型分为 in, ref, out 三种,默认为 in。 * in 类型在子方法中修改了对应变量后,主方法中的值不会发生改变。 * ref 类型在子方法中修改了对应变量后,主方法中的值也会发生改变。 * out 主方法中对应的变量... 阅读全文

posted @ 2008-08-04 17:44 anytime8 阅读(226) 评论(0) 推荐(0)