I've made a class called MyVars
and thats just there to basically store the varibales for use thorughout the entire program. I have tried adding the variables to the same class in a different method but the results are the same. I bascially want to make some variables global so i can use them.
class MyVars
{
public string nameFirst;
public string nameLast;
public int age;
public double height;
}
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Enter first name:");
nameFirst = Console.ReadLine();
Console.WriteLine("Enter last name:");
nameLast = Console.ReadLine();
Console.WriteLine("Enter age:");
age = Console.ReadLine();
}
That's basically the code I've made. Is there a way to make the variables be able to be used in different methods, I don't care about classes yet as I don't mind re-making them for other classes.