Complete noob to C#, converting from Visual Basic, I have been trying to refence class fields in a separate module, tried everything, no good. Moved everything to one module to minimise the accessibility issues, scoped everything public, still can't access fields/properties. I have boiled this down to absolute basics, still can't get it to work. Have tried every possible variation of accessibility (I think).
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
Car MyCar = new Car();
}
public class Car
{
string Manufacturer { get; set; }
string Model { get; set; }
int YearMade { get; set; }
}
private void button1_Click(object sender, EventArgs e)
{
Car.Manufacturer = "Ford";
}
}
Car.Manufacturer in the Click event throws
CS0122 'Form1.Car.Manufacturer' is inaccessible due to its protection level.
If I change the Manufacturer field to public I get this error:
CS0120 An object reference is required for the non-static field, method, or property 'Form1.Car.Manufacturer'
I realise I am doing something stupid here, but how hard can this be?