[.net] [c#] Some class void thing

Started by
10 comments, last by Spoonbender 16 years, 8 months ago
You said you wanted:

cObject.Create.box(bla)
cObject.Create.sphere(bla)
cObject.Create.cilinder(bla)

Here is the pseudo code:
    public class cObject    {        public Create Create = new Create();        class Create        {            public void box(object obj)            {                // your drawing code here            }            public void sphere(object obj)            {                // your drawing code here            }            public void cylinder(object obj)            {                // your drawing code here            }        }    }


You would then access it through the following code:

cObject temp = new cObject();temp.Create.box(blah);temp.Create.sphere(blah);temp.Create.cylinder(blah);

Advertisement
If you want the exact syntax you described, make Create a class.

class cObject {  public static class Create {    public static Box box(...){}    public static Cylinder cylinder(...){}    public static Sphere sphere(...){}  }}Then you can call it the way you described.However, the sane way of doing it would probably be with generics, as someone said above.Then the syntax becomes cObject.Create<Box>() (where Create is a method again)

This topic is closed to new replies.

Advertisement