I don't understand why there is an error saying that the local variable (Month) is not being assigned and I don't understand why.
Code:String Month; if (DateTime.Now.Month.ToString() == "1") { Month = "January"; } else if (DateTime.Now.Month.ToString() == "2") { Month = "February"; } else if (DateTime.Now.Month.ToString() == "3") { Month = "March"; } else if (DateTime.Now.Month.ToString() == "4") { Month = "April"; } else if (DateTime.Now.Month.ToString() == "5") { Month = "May"; } else if (DateTime.Now.Month.ToString() == "6") { Month = "June"; } else if (DateTime.Now.Month.ToString() == "7") { Month = "July"; } else if (DateTime.Now.Month.ToString() == "8") { Month = "August"; } else if (DateTime.Now.Month.ToString() == "9") { Month = "September"; } else if (DateTime.Now.Month.ToString() == "10") { Month = "October"; } else if (DateTime.Now.Month.ToString() == "11") { Month = "November"; } else if (DateTime.Now.Month.ToString() == "12") { Month = "December"; } MessageBox.Show((DateTime.Now.DayOfWeek.ToString()) + " " + Month + " " + (DateTime.Now.Day) + ", " + (DateTime.Now.Year)); }




Reply With Quote