You should separate your classes and use the nested classes as property types.
namespace WindowsFormsApp
{
class Car
{
public Id Id { get; set; }
public Tires Tires { get; set; }
}
public class Id
{
public string brand { get; set; }
public string model { get; set; }
public int year { get; set; }
public string r_no { get; set; }
public string owner { get; set; }
}
public class Tires
{
public string front_value_mm { get; set; }
public string back_value_mm { get; set; }
public bool front_back { get; set; }
}
}
Now you can new-up a car class with the nested values.
var car = new Car
{
Id = new Id
{
brand = "Honda",
model = "Civic",
year = 2017,
r_no = "r_no",
owner = "owner"
},
Tires = new Tires
{
front_value_mm = "front_value_mm",
back_value_mm = "back_value_mm",
front_back = true
}
}
You should then be able to access the nested properties like this.
var brand = Car.Id.brand // Honda
If you want to assign values using parameters you need a constructor method.
solved How to create an object C#