I'm new of the Object Oriented Programming methods:
I have a class MyClass1 as follow:
public class MyClass1
{
public int id { get; set; }
public string name { get; set; }
}
There is also a class MyClass2 defined as:
public class Myclass2
{
public int id { get; set; }
public string name { get; set; }
public Myclass2(MyClass1 m) { }
}
MyClass2 exists only if exists MyClass1, because in MyClass2 I need some properties of the MyClass1.
The best for me will be some like this:
MyClass1.MyClass2 = new MyClass2();
Ofcourse the constructor of MyClass2 should take MyClass1.
What is the best method to achieve this using C# Object Oriented Programming ?
public class Myclass2 : MyClass1 {....MyClass2, it adds nothing. How wouldMyClass2be different?