Link to home
Start Free TrialLog in
Avatar of tmesias
tmesiasFlag for United States of America

asked on

I want masterclass.subclass.function to work ( need easy way to exposing a subclass?)

this probably has a simple answer

I want to create a class library that has itself some sub classes, which in turn have functions.

I mostly want to do this so that the functionality that is being developed for one county in a state to be contained in  a single manageble class.

I want the classes to contain instructions specific to that county, and I expose these as public functions.

Now what I want is to take the classes for each county and put them under a class library for the whole state.

For instance, say I have a class library for colorado, I want to then be able to refrence that colorado class library in another application like this:

ColoradoJobLibrary.CoArapahoeJobs.dosomething

so ColoradoJobLibrary is one object, but then CoArpahoeJobs is another object and dosomething is a function in coArapahoeJobs

I suspect that inheritace, interfaces or imports has something to do with this, but can't quite figure out how to expose the subclass through another class without having to write a property  or function for each function in the county class in the state class.  Is there an easier way?


Avatar of samtran0331
samtran0331
Flag of United States of America image

If you had this in a class file:

Namespace States

    Public Class ColoradoJobLibrary
        Public Class CoArapahoeJobs
            Public Shared Function dosomething() As String
                Return "Hey"
            End Function
        End Class
    End Class

End Namespace


you can then use it on a page by:
Imports YourProjectName.States

and then in page_load you can:
            Response.Write(States.ColoradoJobLibrary.CoArapahoeJobs.dosomething)


of course, you can play with the nesting of classes and/or add more namespaces to 'expose' things the way you want.
Avatar of tmesias

ASKER

Thank you for your reply,

We got the right idea of how I want to be able to refer it but I don't want to write this:

Namespace States

    Public Class ColoradoJobLibrary
        Public Class CoArapahoeJobs
            Public Shared Function dosomething() As String
                Return "Hey"
            End Function
        End Class

        Public Class CoDenverJobs
            Public Shared Function dosomethingelse() As String
                Return "Hey from denver"
            End Function
        End Class
    End Class

End Namespace

I want coDenverJobs and coArapahoeJobs to be different cls files (so I can divide the work of creating them).

ASKER CERTIFIED SOLUTION
Avatar of samtran0331
samtran0331
Flag of United States of America 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 tmesias

ASKER

thanks that's what I was looking for.