今天老师讲的内容相对比较多,把C#入门的一些基础基本都给我们讲了一遍,分为两部分就是讲了数据类型以及常量变量,数据类型又划了几个分支,分别是int,char,string,bool,double,float,datetime.
然后在每个类型下面都做了一点案例,把每种类型的变量返回的值都示范了一下,不同条件以下返回不同的值。
其中我感觉对我来说比较难的就是类型之间的转换,以及string和datetime的一些方式与属性的表达
把这些组合起来可以有非常大的作用,今天老师布置的作业就是用代码来写出如何让用户输入身份证号就可以推断出出生年月日的代码。
public static void Main(string[] args) { Console.WriteLine("please enter your ID number"); string ID=Console.ReadLine(); string year = ID.Substring(6, 4); string month = ID.Substring(10, 2); string day = ID.Substring(12, 2); Console.WriteLine("I think your birthday is "+month+", "+day+", "+year+".");
}
经测试这段代码没有什么问题,但是同时我也在想,能不能在最后输出的时候用Datetime输出呢?
研究了半天也没有搞明白,我会继续研究。
转载于:https://www.cnblogs.com/Dawn-z/archive/2012/10/31/2748767.html
相关资源:ADC1031.pdf ADC1031.pdf