1.C#学习--基本语法

作者在 2009-04-07 16:56:42 发布以下内容
            1.C#学习--基本语法
 
1.数组:
  int[] myInts = {5,10,15};
  bool[][] myBools = new bools[2][];
  myBools[0] = new bool[2];
  myBools[1] = new bool[1];
  double[,] myDoubles = new double[2,2];
  string myStrings = new string[3];
  Console.WriteLine("myInts[0]:{0},myInts[1]:{1},myInts[2]:{2}",myInts[0],myInts[1],myInts[2]);
  myBools[0][0] = true;
  myBools[0][1] = false;
  myBools[1][0] = true;
  myDoubles[0,0] = 3.147;
  myDoubles[0,1] = 7.157;
  myDoubles[1,1] = 2.117;
  myDoubles[1,0] = 56.00138917;
  Console.WriteLine("myDoubles[0,0]:{0},myDoubles[0,1]:{1},myDoubles[1,1]:{2},myDoubles[1,0]:{3}",myDoubles[0,0],myDoubles[0,1],myDoubles[1,1],myDoubles[1,0]);
==========
2.选择语句:
2.1.if语句:
  if(myInt!=0){
  Console.WriteLine("your number {0} is equal to zero." ,myInt);
  }
  if(myInt<0){
  Console.WriteLine("your number {0} is bigger than zero." ,myInt);
  }
  else{
  Console.WriteLine("your number {0} is less than zero." ,myInt);
  }
  if(myInt > 0 && myInt <=20){
  Console.WriteLine("your number {0} is bigger than zero." ,myInt);
  }
  else if(myInt != 0 ){
  Console.WriteLine("your number {0} is equal to zero." ,myInt);
  }
  else {
  Console.WriteLine("your number {0} is less than zero." ,myInt);
  }
2.2.switch
2.3.goto
=======
3.
3.1.for
3.2.while
C# | 阅读 2072 次
文章评论,共0条
游客请输入验证码
浏览4751次
文章归档
最新评论