cshape(c#)学习笔记

1. string str1=Console.ReadLine();//键盘输入的默认为字符串

2.  Console.WriteLine('你的成绩是'+a+'分');

  Console.WriteLine("a={0},b={1}",a,b)

for(i=;i<=;i++)   //for 的格式
{
}

3. while()

4. if  switch goto

5. 交换(方法))函数的写法与引用

 static void Swap(inta,intb)//存疑,可能不是值传递
{
int t;//t的作用范围尽在此大括号内
t=a;a=b;b=t;
}
这样在主函数中交换a,b需要
static void Main(string[] args)
int a=;
int b=;
Swap(ref a, refb)
这样在主函数中交换a,b需要
Swap(a,b)
另外一种写法: //ref共用内存
static void Swap(ref int a,ref int b)//
{
int t;//t的作用范围尽在此大括号内
t=a;a=b;b=t;
}
这样在主函数中交换a,b需要
static void Main(string[] args)
int a=;
int b=;
Swap(ref a, refb)

6. 重载:相同的函数名,但是类型不一样,如

  static void Swap(ref int a,ref int b)            //交换两个数
static void Swap(ref string a,ref string b) //交换两个字符串

write by xdd 2019/07/20


7. 变量类型

int i=1;
double a=3.14159,b=c=d=,e;
bool x=true;
Char ch1='x';
string str1='fengmy';
conse double PI=3.1415926;/定义常数
% //求余数
\n换行  \b退格  \\为右斜杠
int a1=int.Parse(str1); //字符串转为数值方法=子函数
&&与  ||或  !非

8. 变量的有效范围

  局部变量:在类的方法中定义的变量,只在当前方法中有效,不能用于该类其它方法

  在类(不在方法中)中定义的变量成为成员变量,可以分为实例变量、静态变量(也成类变量),如下:

  class Test
{
  int x=;//实例变量,在整个类中有效
  static int y=;//静态变量,所有类中都有效
}

write by xdd  2019-08-19  23:45:55


最新文章

  1. poj 并查集
  2. MapReduce 重要组件——Recordreader组件 [转]
  3. ubuntu cenots 禁止本地登陆
  4. unity中怎样获取全部子物体的组件
  5. Java传参
  6. SQL Server @@ERROR 用法
  7. SSH服务(一)
  8. 程序员需要有多懒 ?- cocos2d-x 数学函数、常用宏粗整理
  9. golang http.client 遇到了 Connection reset by peer 问题
  10. wget命令使用报错 certificate common name &#39;xxx&#39; doesn&#39;t match requestde host name
  11. Linux在VirtualBox的网络设置
  12. JQuery Dom的基本操作
  13. [CodeForces 372A] Counting Kangaroos is Fun
  14. Linux操作系统原理
  15. vscode中live server插件的Go Live不显示问题
  16. 安装lsb_release
  17. CDH5.2+CM5.2+impala2+Spark1.1 集群搭建基础环境准备
  18. 单精度浮点数(float)加法计算出错
  19. vs 你不得不会的调试方式
  20. echarts中跨域动态获取数据时,当某些对应的数据为空时,鼠标滑动到所在位置卡死

热门文章

  1. Ajax自我总结
  2. JDK JRE JVM的区别与关系
  3. Linux 命令行获取天气
  4. Java 干货之深入理解Java泛型
  5. [考试反思]1103csp-s模拟测试99: 美梦
  6. [考试反思]0828NOIP模拟测试32:沉底
  7. CSPS模拟 60
  8. Vue计算属性缓存(computed) vs 方法
  9. Python实现王者荣耀小助手(一)
  10. 1114作业 html