|
-
December 14th, 2011, 03:02 PM
#1
Self Initializing Class (Beginner needs Help)
Ok i am trying to create a class i can use in each of my programs since its reusable code.
For learning purposes i'm working on a networking managemeng type program
So to start off with i have created a class that looks like this
namespace MyCompany
{
public class Network
{
public static List<Segment> holder = new List<Segment>();
public static void Main()
{
// XML Processing in here to populate holder List, it dynamically retrieves teh XML from a SOAP/Web server
}
public List<Segment> getSegments() {
return(holder);
}
public class Segment
{
// Class structure to hold network segment name and an ArrayList of IPs for that segment
}
}
}
in my program i have or want to do something like this
MyCompany.Network network = new MyCompany.Network();
and when i do the above the hope is that the class intiailizes, runs through the Main() and popuplates the holder array so i can then do
List<Segment> segments = network.getSegments(); and my segments list has all my network segment objects already prepopulated.
The problem i am running into is the Main() for MyCompany.Network isn't running and the holder list isn't being populated.. In a simplier example i can't get Main() to run at all (even for something like just counting an int)..
I apologize i am fairly new to C#, i've looked through tutorials and none of them go through anything like this for Classes.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|