為什么會有這個警告?Program.cs(11,17): warning CS0219: The variable `year' is assigned but its value is never used Compilation succeeded - 1 warning(s) 今年是平年
using System;
using System.Collections.Generic;
using System.Text;
namespace Test
{
? ? class Program
? ? {
? ? ? ? static void Main(string[] args)
? ? ? ? {
? ? ? ? ? ? int year = 2015;//年份
? ? ? ? ? ? string text;
? ? ? ? ? ?text= 2015%4==0?"閏年":"平年";//請?zhí)顚懘a
? ? ? ? ? ? Console.WriteLine("今年是{0}",text);
? ? ? ? }
? ? }
}
2022-05-07
應該是
text=year%4==0?"閏年":"平年"
搜索
復制