Link to home
Start Free TrialLog in
Avatar of nvms
nvms

asked on

How to create OOP functionality e.g. x=MajorArea.SubAreas.SpecificMethod(Param1,Param2) etc

I am new to C# and want to create very structured code where I am calling functions and retrieving information via nested processes. I would like each 'item' to be a seperate class file (e.g. class1.cs, class2.cs etc)

I am having difficulty grasping the concepts of C# including the 'using MyThing;' statements after using System.xxx, I know this exposes contents of namespaces but i cannot go any further then firstcall.secondcall

If you can implement the following into a C# code example I would be grateful:

A class called major.cs containing the following:
1) a static parameter I Get and Set e.g. string s=major.strSetting
2) a method which returns a value e.g. int i = major.AddThese(1,2)

Secondary classes called minor1.cs and minor2.cls which contain a method or two

An example of how I can call something like
MyResult = major.minor1.method1(1,2,3)

I am sure a good example of this will help other new users also.
ASKER CERTIFIED SOLUTION
Avatar of DaniPro
DaniPro
Flag of Italy image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Sijin
Sijin

What you want can be done using nested classes, the only problem is that minor1 and minor2 cannot be in seperate class files, they have to be in the same file as major.

class Major
{

public staitc string strSetting=null;

public int AddThese(int a,int b)
{
return a+b;
}

    //This is an InnerClass
    public class Minor1
    {
         public static int method1(int a,int b,int c)
         {
               return 0;
          }
     }
}



Avatar of nvms

ASKER

Thanks, good advice