C#基础(1)——快捷\注释\使用
来源:互联网 发布:图片特效软件 编辑:程序博客网 时间:2024/05/22 06:50
输出与暂停
Consel.WriteLine("hello");Consel.ReadKey();//暂停
快捷键
Ctrl+K+D——快速对齐代码
Ctrl+J——代码提示
Ctrl+L——删除行
Ctrl+Shift+Enter——换下行
Ctrl+Enter——换上行
Alt+↑——移动当前行,往上
Ctrl+Z——撤销
Ctrl+Y——恢复
Shift+Home——选中一行到头
Shift+End——选中一行到尾
Shift+↑——选中一行到上一行
F1——转到帮助文档
折叠代码:
#region 这些是冗余代码
代码
#endregion
注释
using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading.Tasks;namespace ChuangzhiConsel{ class Program { static void Main(string[] args) { } /// <summary> /// 取最大值 /// </summary> /// <param name="n1">第一个参数</param> /// <param name="n2">第二个参数</param> /// <returns></returns> public static int GetMax(int n1, int n2) { return n1 > n2 ? n1 : n2; } } /// <summary> /// 用来描述信息 /// </summary> public class Person { public string name { get; set; } public int age { get; set; } }}
类型
string 字符串””
char 字符”
decimal money=5000m;金钱类型一定要有m
double
float
int
变量使用规则
先声明、再赋值,最后使用。
String与string的区别
运行没区别,String是系统的,string是C#里的关键字,最后都映射到同一个。
像Python一样使用占位符:
安装挖坑的顺序输出。
using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading.Tasks;namespace ChuangzhiConsel{ class Program { static void Main(string[] args) { String name1 = "张三"; String name2 = "李四"; Console.WriteLine("hello,{0} with {1}",name1,name2); Console.ReadKey(); } }}
变量命名规则
保证变量名有实际意义,Camel,首单词首字母小写,区别的单词大写。字母开头、下划线、数字等组成,大小写敏感。HTML是不区分大小写的。变量名不允许重复的声明和定义。
类或方法命名
每个单词首字母大写,Pascal
不使用第三方变量交换
using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading.Tasks;namespace ChuangzhiConsel{ class Program { static void Main(string[] args) { int n1, n2; n1 = 35; n2 = 655; n1 = n1 - n2; n2 = n1 + n2; n1 = n2 - n1; Console.WriteLine("n1是{0},n2是{1}",n1,n2); Console.ReadKey(); } }}
控制台程序
using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading.Tasks;namespace ChuangzhiConsel{ class Program { static void Main(string[] args) { Console.WriteLine("n1是:"); String str = Console.ReadLine();//接收控制台的输入 Console.WriteLine("n1是{0}", str); Console.ReadKey(); } }}
阅读全文
0 0
- C#基础(1)——快捷\注释\使用
- C# 注释快捷
- xcode 8.0 快捷注释无法使用
- JSP基础语法(1)——HTML注释
- 快捷选中一行,快捷注释
- C#使用XML注释
- 浏览器快捷使用方式——vimium
- Java基础——注释
- Java基础--------(1)注释
- 使用搜狗输入法实现对代码快捷注释
- 使用Visual Assist X进行快捷doxygen模板注释
- eclipse 注释快捷
- Eclipse 快捷注释
- 快捷注释方式
- VS注释快捷
- Xcode8 快捷注释失败
- android_快捷注释
- VS2005 注释模板 快捷注释 注释快捷键
- spring的bug记录
- 网上找了一个算法题练练手
- 后台截图(六)
- 命令行创建angular新项目
- java 线程的join方法解析
- C#基础(1)——快捷\注释\使用
- 分数化小数
- 动态规划之完全背包问题杭电1114
- Python 笔记
- K-th Number
- 数字图像处理之卷积、模板
- LaTex(PART VI) 摘要和关键字
- C++中strcmp的头文件问题
- 【bzoj 1191】超级英雄Hero(网络流)