Re: making Array of objects of a class

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: clyyy2002 (clyyy2002_at_yahoo.com.cn)
Date: 07/28/04


Date: Wed, 28 Jul 2004 15:46:34 +0800


try to

using System;
using System.Collections;

namespace Student1

{

    class ABC

    {

    private

    string strname;

    public void GetData()

    {

        Console.WriteLine("Enter your Name");

        strname = Console.ReadLine();

    }

    public void Print()

    {

        Console.WriteLine(strname);

    }

};

class Class1

{

[STAThread]

static void Main(string[] args)

{

ABC[] arr = new ABC[6];

for(int i=0;i<arr.Length;i++)
{
 arr[i] = new ABC();
}

arr[0].GetData(); // This Line gives exception?

arr[0].Print();

}

}

}



Relevant Pages

  • Re: column limit in a data set
    ... [STAThread] ... static void Main(stringargs) ... Joel Martinez ...
    (microsoft.public.dotnet.languages.csharp)
  • Specifying command-line arguments w/WinForms mangles Form
    ... following manner: ... [STAThread] ... static void Main(stringargs) ...
    (microsoft.public.dotnet.languages.csharp)
  • Enterprise Instrumentation framework
    ... So I try to make a small lab on EIF, I block on the level of the file ... [STAThread] ... static void Main(stringargs){ ...
    (microsoft.public.dotnet.distributed_apps)
  • Memory Not Being Claimed
    ... [STAThread] ... static void Main(stringargs) ...
    (microsoft.public.dotnet.framework.clr)
  • Little question
    ... private static void PrintTheRobots ... [STAThread] ... static void Main(stringargs) ... Result is that no robots are left in the ArrayList al. ...
    (microsoft.public.dotnet.languages.csharp)