零基础学习c#的第一天 一、基础环境安装去微软官方下载visual studio即可自己网上搜索也行二、编写第一个程序helloworldusing System; namespace basecode { class Program { static void Main(string[] args) { //打印hello world Console.WriteLine(hello world !);//输出后自动换行 Console.Write(hello world !);//不换行 } } }三、今日语法总结1.变量类型int age 20; //整型 double pi 3.1415926; //精度更高但仍然有误差 float distance 2.34F; //需要加f大小写都可以用来区分double decimal price 19.99M; //显示余额用decimal精度更高 bool flag true; //布尔类型只有true和false不可用0和1代替 char c A; //字符 string greeting Hello boys and guys !; //字符串2.格式化输出//格式化输出 int a 2; int b 3; int result a b; Console.WriteLine({0} {1} {2}, a, b, result); //不推荐 Console.WriteLine(${a} {b} {result});//推荐3.将int转换成string类型int height 123; //两种方式 string s height; string text Convert.ToString(height);4.输入string inputStr Console.ReadLine(); //读取一行字符串 Console.WriteLine(inputStr); int inputInt int.Parse(Console.ReadLine()); //读取一个整数 double inputDouble double.Parse(Console.ReadLine()); //读取浮点数 Console.WriteLine($int: {inputInt} double: {inputDouble}); //读取多个值 string[] inputs Console.ReadLine().Split( );//通过空格分割字符串存入字符串数组 //下面是两种不同的转换方式 int one int.Parse(inputs[0]); int two Convert.ToInt32(inputs[1]); Console.WriteLine(${one} {two});5.类的简单调用using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace basecode { class Person { public int agePerson { get; set; }//自动属性 public string namePerson { get; set; } public Person() { } public Person(int age, string name) { agePerson age; namePerson name; } public void showInfo() { Console.WriteLine($姓名{namePerson} 年龄{agePerson}); } } }//简单调用类 Person p1 new Person(); p1.agePerson 20; p1.namePerson 佘豪; p1.showInfo();四、今日总结对于以上代码不仅要看懂还得动手敲才能够真正的融会贯通我的座右铭是多学习多实践