473,396 Members | 1,853 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.

I'm obviously just missing something REALLY simple


I'm sure once someone answers this I'll feel really dumb.

I'm a c++ programmer playing with c# an here's my conundrum

I declare a class in the for

public class Form1 : System.Windows.Forms.For
class Class

public int

ge

return x

se

x = value

}
..
I declare an array of the class in the body of the form as a member of the form

ClassA [] ClassAArray = new ClassA[10]

In the Consructor of the form I init the array (this is probably what I'm messing up

public Form1(

InitializeComponent()

for(int i = 0 ; i < 10 ; i++

ClassAArray[i]= new ClassA()

When I try to access the member "i" it's not initialized, and i get a stack overflow exception

private void button1_Click(object sender, System.EventArgs e

ClassAArray[0].x = 0
Orinigally did this with a string member, but the same thing happens with and int member

Can anyone tell me what I'm missing about creating an instance of an array of a class

Thanks

Eric

Nov 16 '05 #1
2 1199
Caladin wrote:
public int x
{
get
{
return x;
}
set
{
x = value;
}
} When I try to access the member "i" it's not initialized, and i get a
stack overflow exception.


A stack overflow exception is precisely what I'd expect this code to throw;
it's an infinite loop. Here's a template that will solve your problem:

public class foo {
protected int _x;
public int x {
get { return _x; }
set { _x = value; }
}
}

--
Gravity: it's not just a good idea, it's the law.
Nov 16 '05 #2

Ah I see, got it , thanks

Cal-
Nov 16 '05 #3

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

Similar topics

99
by: Jim Hubbard | last post by:
It seems that Microsoft not only does not need the classic Visual Basic developer army (the largest army of developers the world has ever seen), but now they don't need ANY Windows developer at a...
13
by: Eric Pederson | last post by:
Raise your hand if you think the best technology wins! For those of you with your hands in the air, tell me: if Python is so good,why has PHP achieved such greater adoption and mindshare? Why...
102
by: Skybuck Flying | last post by:
Sometime ago on the comp.lang.c, I saw a teacher's post asking why C compilers produce so many error messages as soon as a closing bracket is missing. The response was simply because the compiler...
3
by: Javaman59 | last post by:
Visual Studio 2003/5 question... I'm in the solution explorer, looking at a file. I want to find it's path. The only way i know of doing this is to open it (with a double-click), then mouse over...
17
by: Justin Emlay | last post by:
I'm hopping someone can help me out on a payroll project I need to implement. To start we are dealing with payroll periods. So we are dealing with an exact 10 days (Monday - Friday, 2 weeks). ...
11
by: Nicky Smith | last post by:
Hello, I'm studying a book on VB.net Win apps, and I'm reading a section on events and delegates and raising events. Is it just me, or is this not just subs dressed up as something else? I...
6
by: Sam Malone | last post by:
Am I just totally missing something here? I'm just new to VS.NET 2005 (using VB.NET) and ADO.NET. I get the impression that ADO.NET can't do what I'm used to doing with ADO (previous ADO...
3
by: shawnews | last post by:
Hi, I try to apply a simple tag to an image like that: <td><img src="../images/lower-left-corner.png" alt="lower-left-corner" width="26" height="19" class="right-middle" /></td> the css-tag...
1
by: chadw | last post by:
Not sure what I am missing sure its probably something very simple, I need something to get my entered text out of the textbox and entered into a database currently the code looks like this. ...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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...

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.