1. int a=1234,b=-1234;
输出:
a=1234,b=-1234
a=01234,b=-01234
a=¥1,234,000 , b=¥-1,234,000
int a = 1234, b = -1234;
Console.WriteLine("a={0},b={1}", a, b);
Console.WriteLine("a={0:D5},b={1:D5}", a, b);
Console.WriteLine("a={0:c3},b={1:c2}",a,b);
2.double d=123.456;
输出:
¥123.46
1.2346E+002
123.4560
123.456
123.46
double d = 123.456;
Console.WriteLine("{0,5:c}", d);
Console.WriteLine("{0:E4}", d);
Console.WriteLine("{0:f4}", d);
Console.WriteLine("{0:g}", d);
Console.WriteLine("{0:n}", d);
3.声明一个学生结构类型Stud,包含学号、姓名和出生日期成员;定义Stud结构的两个学生s1,s2并赋值,求他们出生在星期几以及他们的出生相差的天数
enum WeekDay {
星期日,星期一,星期二,星期三,星期四,星期五,星期六};
class Program
{
public struct Stud
{
public int num;
public string name;
public DateTime brithday;
}
static void Main(string[] args)
{
//思路1
Stud s1 = new Stud();
Stud s2 = new Stud();
s1.name = "李明";
s1.num = 1;
s1.brithday = new DateTime(1985, 10, 18)