private void btnAgePredict_Click(object sender, EventArgs e) { var client = new AgePredictServiceClient(); DateTime birthDate; if (DateTime.TryParse(txtAgePredict.Text, out birthDate)) { var result = client.GetDateOnEvenThousandDay(birthDate); lblResult.Text = "Du fyller jämna tusen dagar " + result.ToShortDateString(); } else lblResult.Text = txtAgeService.Text + " funkar inte som en datum"; }
private static void DoAgePredictServicePart() { var client = new AgePredictServiceClient(); DateTime answerDate; do { Console.Write("Skriv ditt födelseår (Format exempel: 1980-11-02):"); } while (!DateTime.TryParse(Console.ReadLine(), out answerDate)) ; var result = client.GetDateOnEvenThousandDay(answerDate); Console.WriteLine("Datum då du fyller jämt tusental dagar: " + result.ToShortDateString()); Console.WriteLine(); }