First of all, as your colleague ZottoSL mentions you, what you are mentioning as Classes are actually Methods . A class is just a container that has N methods or functions.
I clarify this, to do what you want you must call Class2 within Class1 and pass as a parameter to Class2 , which receives < em> Class1 .
public class Vehiculo
{
public void Atributos(string color)
{
Auto auto = new Auto();
auto.SetColor(color);
}
}
public class Auto
{
private string color { get; set }
public void SetColor(string color)
{
this.color = color;
}
}
Now, if your method2 does not receive parameters (as it is in this case), you must set the property directly.
public class Vehiculo
{
public void Atributos(string color)
{
Auto auto = new Auto();
auto.color = color;
}
}
public class Auto
{
public string color { get; set }
}
You tell us how you are doing =)