473,396 Members | 1,907 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Does C# support array of classes?


I'm following a tutorial tour for Microsoft C# and I ask if
this language supports array of classes like C++.That's a
personal curiosity.
I add the body of the two .cs files of my project which works fine but
commented-out lines:

using System;

namespace My3
{
/// <summary>
/// Summary description for CAMix.
/// </summary>
public class CAMix
{
public CAMix()
{
//
// TODO: Add constructor logic here
//
}
public int i_Y;
}
}

using System;

namespace My3
{
class CMix
{
public int i_Y;
}

struct SMix
{
public int i_Y;
}
/// <summary>
/// Summary description for Class1.
/// </summary>
class Class1
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main(string[] args)
{
//
// TODO: Add code to start application here
//
CMix c_Mix1 = new CMix();
CMix[] c_Mix2 = new CMix[4];
CAMix[] c_Mix3 = new CAMix[4];

SMix s_Mix1;
SMix s_Mix2 = new SMix();
SMix[] s_Mix3 = new SMix[7];

c_Mix1.i_Y = 8;
Console.WriteLine("c_Mix1.i_Y = " + c_Mix1.i_Y.ToString());
/*for (int i_Index = 0; i_Index < c_Mix2.Length; i_Index++)
c_Mix2[0].i_Y = i_Index * 100;*/
/*for (int i_Index = 0; i_Index < c_Mix3.Length; i_Index++)
c_Mix3[0].i_Y = i_Index * 100;*/

s_Mix1.i_Y = 3;
Console.WriteLine("s_Mix1.i_Y = " + s_Mix1.i_Y.ToString());
s_Mix2.i_Y = 15;
Console.WriteLine("s_Mix2.i_Y = " + s_Mix2.i_Y.ToString());
for (int i_Index = 0; i_Index < s_Mix3.Length; i_Index++)
{
s_Mix3[i_Index].i_Y = i_Index * 10;
Console.WriteLine("s_Mix3[{0}].i_Y = " +
s_Mix3[i_Index].i_Y.ToString(), i_Index);
}
}
}
}

This text editor isn't wonderful,but I rely on your wonderful will.
regards
Mr. Trevisan Andrea

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 15 '05 #1
3 11899
Dear Andrea,

I don't know about C++ but C# has Types with which you can do loads of
classy stuff (pun intended).

See my post in the thread "opening form by name" in which you can see
how knowing the name of a form (which is also its class name) is enough to
create and display an instance of the form using Types (and Reflection).

With an array of Types you can do similar things and more for any
class/type.

Hope this piques your curiousity to study Reflection - it's very
powerful.

Best wishes,
Fergus
Nov 15 '05 #2
Hi Fergus,

I believe what Andrea wanted is "array of objects", or "array of class
instances." It is different from "array of Type objects", which I admit is
very useful. Thanks,

- Zhanyong Wan

Visual Studio and .NET Setup

This posting is provided "AS IS" with no warranties, and confers no rights.
Use of included samples (if any) is subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm
--------------------
| From: "Fergus Cooney" <wo****@tesco.net>
| References: <us**************@TK2MSFTNGP12.phx.gbl>
| Subject: Re: Does C# support array of classes?
| Date: Sun, 24 Aug 2003 02:37:38 +0100
| Lines: 19
| X-Priority: 3
| X-MSMail-Priority: Normal
| X-Newsreader: Microsoft Outlook Express 6.00.2600.0000
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000
| Message-ID: <ek**************@tk2msftngp13.phx.gbl>
| Newsgroups: microsoft.public.dotnet.languages.csharp
| NNTP-Posting-Host: m55-mp1.cvx3-a.bre.dial.ntli.net 62.255.96.55
| Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!tk2msftn gp13.phx.gbl
| Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.languages.csharp:178913
| X-Tomcat-NG: microsoft.public.dotnet.languages.csharp
|
| Dear Andrea,
|
| I don't know about C++ but C# has Types with which you can do loads of
| classy stuff (pun intended).
|
| See my post in the thread "opening form by name" in which you can see
| how knowing the name of a form (which is also its class name) is enough to
| create and display an instance of the form using Types (and Reflection).
|
| With an array of Types you can do similar things and more for any
| class/type.
|
| Hope this piques your curiousity to study Reflection - it's very
| powerful.
|
| Best wishes,
| Fergus
|
|
|

Nov 15 '05 #3
Hi Zhanyong,

Reckon you're right there. :-)

And, on reflection (no pun this time), I'm aiming a bit further
into her future with .NET!

Regards,
Fergus
Nov 15 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Phil Powell | last post by:
if (is_array($_POST)) { foreach ($this->getAssocSectionsObjArray($key, $dbAP) as $obj) { print_r($obj); print_r(" in array? "); print_r(in_array($obj, $result)); print_r("<P>"); if...
30
by: Christian Seberino | last post by:
How does Ruby compare to Python?? How good is DESIGN of Ruby compared to Python? Python's design is godly. I'm wondering if Ruby's is godly too. I've heard it has solid OOP design but then...
1
by: Daniel | last post by:
does C# have any collection objects that support sort functionality so that I dont have to write my own sorting algorithm?
13
by: Jason Huang | last post by:
Hi, Would someone explain the following coding more detail for me? What's the ( ) for? CurrentText = (TextBox)e.Item.Cells.Controls; Thanks. Jason
7
by: Ron | last post by:
Hello, I have 4 classes that use 4 DTS packages on 4 different tables. So I have Dim cls1 As New clsDTS1, cls2 As New clsDTS2 Dim cls3 As New clsDTS3, cls4 As New clsDTS4 Each class has a...
14
by: Anoop | last post by:
Hi, I am new to this newsgroup and need help in the following questions. 1. I am workin' on a GUI application. Does C# provides Layout Managers the way Java does to design GUI? I know that it...
15
by: Pucca | last post by:
I'm getting an error when I tried to use this BerConverter class in my C# code. Even though the Interent doc says that it runs on Win2000 sp4, I just thgouth I'll double check. Does anyone know...
5
by: =?Utf-8?B?TWFydHluIEZld3RyZWxs?= | last post by:
From the amount of articles about this one I’m sure this gets asked a lot, but I haven’t yet found a succinct article which explains what is required in its entirety. I work using Visual...
8
by: Bill McCormick | last post by:
<!-- When deploying the service library project, the content of the config file must be added to the host's app.config file. System.Configuration does not support config files for libraries. --> ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.