학생 정보 및 유학생을위한 별도의 수업으로 Windows 양식을 만들고 있습니다. 학생/유학생을위한 Year Mark가 0 이상 100 미만임을 확인해야합니다.numeric 및 DateTime 입력의 구문 분석 및 유효화
생년월일을 dd/mm/yyyy로 표시하고 싶지만 현재 그 시간 플러스.
나는 아래의 코드가 포함됩니다되는 것입니다 날짜에 대한 ToString()
기능의 과부하가 올해 마크
try // Trying to do the thing in the curly braces
{
student1.YearMark = Int32.Parse(txtYearMark.Text);
}
catch (Exception) // If it doesn't work skip the crash and print this
{
MessageBox.Show("The Year mark must be a number and can't be empty");
}
그것은 완전한 대답 아니지만, 날짜 시간에 TryParse 방법을 사용하여 시도하고 결과의 다양한 속성을보고있다 DateTime 인스턴스입니다. – MNGwinn