I’m new to C# and have a question regarding classes. At the moment I use simple classes for example:
public class Core
{
public double Parameter1;
public double Parameter2;
public double Calc1()
{
return(Parameter1 * Paramater2);
}
}
In my main code I then create an object of the class, and use it as follows:
Core core = new Core();
core.Parameter1 = 2;
core.Parameter2 = 3;
double x = core.Calc1();
Now my question is, how do I structure classes to have for example the following functionalities:
core.Calculations.Calc1();
core.Calculations.Calc2();
At the moment I can only have core.Calc1() etc not core.Calculations.Calc1();
I use code such as the following many times from existing libraries, and I need to do the same:
zedDistVectorAAR.AccessibilityObject.Bounds.Bottom.CompareTo();
I have no idea how to structure such classes.
I have tried all types of classes from nested to everything in the book but I cannot get a structure such as the above one. Since it is used everywhere I’m missing something. I have really looked through many articles and books but my lack of formal IT education and lack of the correct terminologies are really getting me down.
For example what I want to do is I want to have a class, that can give me different price quotes:
double open = data.Financial.Open;
double close = data.Financial.Close;
How can I achieve this?
Any help will be appreciated 🙂
do you need to have that class instanced?
for example with
you could get
otherwise you could do something like this
and acces str with