C#基础操作
using System; //引入命名空间 namespace name{ //类名 class Program{ //main方法 static void Main(string[] args) { //打印输出 Console.WriteLine("Hello Word") } } }
注释快捷键:ctrl+k+c 取消: ctrl+k+u
F5直接运行程序
\t =tab键 \n=换行
创建:使用C#控制台应用程序
快速对齐:ctrl + k+d
弹出智能提示:ctrl+j
生产main方法:svm+Tab
自动包括选中代码:ctrl+k+s
const:常量(不能被改变)
const float i =3.14f;
注意:必须在定义时就初始化数据
用户输入
String str = Console.ReadLine(); //读取并赋值 输入 Console.WriteLine(" str+"hh" ");// 输出str+hh 注:如果直接输入整数需转换 //Console.ReadLine默认接受字符串 字符串不可以做运算。 String str = Console.ReadLine(); int strInt = Convert.ToInt32(str);//不能转换非数字的 如‘fd’ Console.WriteLine(" str+"hh" "); 简写: int a = Convert.ToInt32(Console.ReadLine()); Console.WriteLine("a");