首页 > Windows开发 > 详细

C#学习笔记---xdd

时间:2019-07-20 22:59:51      阅读:110      评论:0      收藏:0      [点我收藏+]

 

  1. 1 string str1=Console.ReadLine();//键盘输入的默认为字符串
    2 Console.WriteLine("a={0},b={1}",a,b)
    3 int a1=int.Parse(str1); //字符串转为数值

     

  2. 方法=子函数
  3. for(i=3;i<=10;i++)   //for 的格式
    {
    }

     

  4. while()
  5. if  switch goto   
  6. 交换(方法))函数的写法与引用
  7. 1 static void Swap(inta,intb)//存疑,可能不是值传递
    2 {
    3 int t;//t的作用范围尽在此大括号内
    4 t=a;a=b;b=t;
    5 }
    这样在主函数中交换a,b需要
    static void Main(string[] args)
      int a=1;
      int b=2;
      Swap(ref a, refb)
    这样在主函数中交换a,b需要
    
    Swap(a,b)
     
    
    另外一种写法:       //ref共用内存
    1 static void Swap(ref int a,ref int b)//
    2 {
    3   int t;//t的作用范围尽在此大括号内
    4   t=a;a=b;b=t;
    5 }
    这样在主函数中交换a,b需要
    static void Main(string[] args)
      int a=1;
      int b=2;
      Swap(ref a, refb)
  8. 重载:相同的函数名,但是类型不一样,如
  9. 1  static void Swap(ref int a,ref int b)            //交换两个数
    2  static void Swap(ref string a,ref string b)    //交换两个字符串
  10. write by xdd 2019/07/20

技术分享图片

 

C#学习笔记---xdd

原文:https://www.cnblogs.com/xdd1997/p/11219434.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!