Try like this:
using System;
namespace MyApplication
{
class Program
{
static void Main(string[] args)
{
Car myObj = new Car();
Console.WriteLine(myObj.color);
Console.WriteLine(myObj.maxSpeed);
}
public class Car
{
public string color = "red";
public int maxSpeed = 200;
}
}
}
It's also possible to put the Car class outside the Program class:
class Car
{
public string color = "red";
public int maxSpeed = 200;
}
In fact it is recommended to put each class in it's own file, but for such a small example it is not necessary.
Note that the use of Access modifiers like Public for a class differs when using a Console or Winforms application, the Console application sometimes does not like it.