Hi fss199,
正如[-]所说的那样,“DateTime.AddYears(Int32)”存在一个“DateTime”类型的返回值。所以你需要如下修改代码。
DateTime dt1 = System.DateTime.Now.AddYears(1);
Console.WriteLine(dt1.ToShortDateString());
DateTime dt2 = System.DateTime.Now;
dt2 = dt2.AddYears(1);
Console.WriteLine(dt2.ToShortDateString());
Regards,
Kyle
MSDN Community Support
Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to
MSDN Support, feel free to contact MSDNFSF@microsoft.com.