repl.it
@kironroy/

typeconvert

C#

C# type conversion

fork
loading
Files
  • main.cs
  • main.exe
main.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
using System;

class MainClass {
  public static void Main (string[] args) 
  {
       Console.WriteLine("Write is your age: ");
      string ageText = Console.ReadLine();

      bool isValidAge = int.TryParse(ageText, out int age);


      while (isValidAge == false)
      {
          Console.WriteLine("What is your age: \nType a number: ");
          ageText = Console.ReadLine();

          isValidAge = int.TryParse(ageText, out age);
      } 

      Console.WriteLine($"In ten years you will be: {age += 10} years old.");

      Console.ReadLine();
  }
}