There are many similar questions here but I could not understand why can't I use them in C# but in other languages. How does this code work if I am not using try catch block but expects me to initialize the variables when I am using it. How does memory allocation takes place in this case. P.S. I am a beginner and some of these thing make limited sense to me.
using System;
public class Example
{
   public static void Main()
    {
    int user=0, pass=0;
    do
    {
        Console.WriteLine("Enter the username");
        try
        {
            user = Convert.ToInt32(Console.ReadLine());
            Console.WriteLine("Enter the password");
            pass = Convert.ToInt32(Console.ReadLine());
            if (user == 12 && pass == 1234)
                Console.WriteLine("Correct");
            else
                Console.WriteLine("Invalid Username or Password");
            Console.ReadKey();
        }
        catch (FormatException)
        {
            Console.WriteLine("Invalid Format");
        }
        catch (OverflowException)
        {
            Console.WriteLine("Overflow");
        }
    }
    while (user != 12 && pass != 1234);
}
    }
 
     
    