Pretty new to C# -- I was instructed to create a subclass to do a variation of the base class. Never having done sub classes before, I read a bit and then tried it out. I could only access the private property of MyClass from the sub class after inheriting from the base class. What have I done here? Is this a true sub class, or some sort of nested inheriting one?
public class MyClass
{
private string connString;
// exec stored procedure 1
public class MySubClass : MyClass
{
otherClass o = new otherClass(connString);
// exec stored procedure 2
}
}
Whatever I did, it seems to work. Also, while on the topic of sub classes, is there a common way to name them? e.g. MyClass_SubClass, or _MyClass etc?
Thanks much!
Edit: Thanks again, everyone! I think I was looking for this answer here. Regardless, I realized that I'd misunderstood the task -- no need for nesting or inheritance at all! Just created a separate similar class.