Hello,
I've been learning C# for a few months. I'm currently trying to explore the capabilities of classes in C#. Especially the concepts of Inheritance, Polymorphism, and Regression.
I'm getting stumped on a case scenario and I'm hoping someone can clarify the limits and methodology of it.
The concept is this: 1) Create a base class that contains a data class to be used as the base object for other classes.
2) the second class would inherit from the base class and define/extend on the data class.
I put together an example of what I'm trying to do as basically as I could:
Since this is a concept used there is no other data behind it. I tried different approaches to instantiating the FirstClass, but left it out for simplicity.
Business cases could be anything that pulls data and manipulates it, a web api, a json file, or any other type.
Thank you,
I've been learning C# for a few months. I'm currently trying to explore the capabilities of classes in C#. Especially the concepts of Inheritance, Polymorphism, and Regression.
I'm getting stumped on a case scenario and I'm hoping someone can clarify the limits and methodology of it.
The concept is this: 1) Create a base class that contains a data class to be used as the base object for other classes.
2) the second class would inherit from the base class and define/extend on the data class.
I put together an example of what I'm trying to do as basically as I could:
C#:
namespace ClassExample
{
public class FirstClass
{
public class MyClass {
//to be determine (elements of this data class) in the final class
}
public List<MyClass> myClass(MyClass item1, MyClass item2)
{
var myList = new List<MyClass> {
item1,
item2
};
return myList;
}
}
public class SecondClass : FirstClass
{
public class MyClass2 : MyClass
{
public string myName;
public string myDescription;
}
public SecondClass()
{
List<MyClass2> myList2 = new List<MyClass2>();
MyClass2 myItem1 = new MyClass2();
myItem1.myName = "John";
myItem1.myDescription = "JOhn is my name";
MyClass2 myItem2 = new MyClass2();
myItem2.myName = "Mary";
myItem2.myDescription = "Mary is my name";
myList2 = myClass(myItem1, myItem2);
}
}
}
Since this is a concept used there is no other data behind it. I tried different approaches to instantiating the FirstClass, but left it out for simplicity.
Business cases could be anything that pulls data and manipulates it, a web api, a json file, or any other type.
Thank you,