So i started learning c# a few days ago and i started making a simple multiplier program:
using System;
namespace learning_the_syntax
{
public class GlobalVariables //this class stores all global variables i want to use. Local variables will be stored inside their function/method
{
int num01;
int num02;
}
class MainClass
{
public static void Main(string[] args) //This is a function/method named "Main". It is called when the program starts.
{
Console.WriteLine("Type a number to be multipied: ");
num01 = Console.ReadLine();
}
}
}
I created a public class to store my global variables but when i tried to use the variable num01
in my Main
class, it shows an error message stating that num01
does not exist in its current context. Can anybody help please? Thank you.