Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. regd C# classes

regd C# classes

Scheduled Pinned Locked Moved C#
questioncsharpdata-structures
4 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • K Offline
    K Offline
    karteek
    wrote on last edited by
    #1

    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

    C S E 3 Replies Last reply
    0
    • K karteek

      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

      C Offline
      C Offline
      Charlie Williams
      wrote on last edited by
      #2

      Use an ArrayList, which will expand automatically as you add new objects. Charlie if(!curlies){ return; }

      1 Reply Last reply
      0
      • K karteek

        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

        S Offline
        S Offline
        sreejith ss nair
        wrote on last edited by
        #3

        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

        1 Reply Last reply
        0
        • K karteek

          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

          E Offline
          E Offline
          etfintnick
          wrote on last edited by
          #4

          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

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups