So I started learning Classes in C#, and can't understand what classes exactly are and how they differ from structures (I know that they are reference and value types resp. but I'm not exactly sure what these types are).
I have the following code:
class Info
{
public string Name;
public int Age;
}
class Program
{
static void Main()
{
Info APersonsAccount;
APersonsAccount = new Info();
APersonsAccount.Name = "NameOfPerson";
APersonsAccount.Age = 23;
Console.Write("Name: {0,-15} Age: {1,-20}", APersonsAccount.Name, APersonsAccount.Age);
}
}
What I don't understand is how the code works. More precisely, what these lines mean-
Info APersonsAccount;
APersonsAccount = new Info();
The variable of the class Info is declared in the first line so why do we need to write the second line? What exactly happens at each step when this code is executed?