regd C# classes
-
Hi, I defined a class. Now I want to define an array of classes. I don't know the size of the array. How do I define it then?? Karteek
Use an
ArrayList
, which will expand automatically as you add new objects. Charlie if(!curlies){ return; } -
Hi, I defined a class. Now I want to define an array of classes. I don't know the size of the array. How do I define it then?? Karteek
1. Array of class if you know the size. using System; namespace ClsArray { class Cls { public string Name; public Cls(){} public Cls(string name){this.Name=name;} public static void Main() { Cls[] obj=new Cls[2]; obj[0]=new Cls("myname"); obj[1]=new Cls("yourname"); for(int i=0; i
-
Hi, I defined a class. Now I want to define an array of classes. I don't know the size of the array. How do I define it then?? Karteek
You could put it all in an Arraylist if you're not concerned about wether it should be strong-typed or not. As an alternate option, you could make your own MyClassNamehereCollection, ie. dervice a class from System.Collections.CollectionBase R.a.m