示例代码:
1 2 |
string s = "Hello world!"; String S = "Hello world!"; |
string是System.String的C#中的别名。 所以理论上没有区别。 就像int与System.Int32的关系一样。 继续阅读“C#中String和string的区别”
走走停停,看日出!
示例代码:
1 2 |
string s = "Hello world!"; String S = "Hello world!"; |
string是System.String的C#中的别名。 所以理论上没有区别。 就像int与System.Int32的关系一样。 继续阅读“C#中String和string的区别”
在实际开发中有时会根据生日 DateTime
即出生年月日计算出现在的年龄,可以使用下面的代码快速实现。
1 2 3 4 5 6 |
// 当前日期. var today = DateTime.Today; // 计算年龄. var age = today.Year - birthdate.Year; // 判断生日是否已过,返回真实年龄 if (birthdate > today.AddYears(-age)) age--; |