473,405 Members | 2,261 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,405 software developers and data experts.

Q: property problem (enum)

hi all,

I want to create a property in class (datatype=enum).
In one other class I have declaration of enum:

public enum enumCrep

{

cRep1 = 1,

cRep2 = 2,

}

now, I want to create a property:

public enumCrep ecRep

{

get { return this.ecRep;}

set {this.ecRep = value;}

}

at the moment of asignig a value to this propery its raises error:

{Cannot evaluate expression because the current thread is in a stack
overflow state.}

thanks for help in advance


Mar 23 '06 #1
3 10794
Hi,

You need a member variable to hold the value of the enum

eg
protected enumCrep mecRep

public enumCrep ecRep
{

get { return mecRep;}

set {mecRep = value;}
}

Your code goes into recursion (i.e. you are setting property which is
in-turn calling the code which sets it again)

HTH
Kalpesh

Mar 23 '06 #2

"Kalpesh" <sh*********@gmail.com> wrote in message
news:11**********************@j33g2000cwa.googlegr oups.com...

yeah! its works! :))
thanks for fast help
Mar 23 '06 #3
Youre property is referencing itself, which causes a stack overflow due to
infinte recursion. Try:

private enumCrep _ecRep;
public enumCrep ecRep
{
get { return _ecRep;}
set {_ecRep = value;}
}

--
HTH,

Kevin Spencer
Microsoft MVP
Professional Numbskull

Show me your certification without works,
and I'll show my certification
*by* my works.
"dllhell" <dl*****@gmail.com> wrote in message
news:dv**********@sunce.iskon.hr...
hi all,

I want to create a property in class (datatype=enum).
In one other class I have declaration of enum:

public enum enumCrep

{

cRep1 = 1,

cRep2 = 2,

}

now, I want to create a property:

public enumCrep ecRep

{

get { return this.ecRep;}

set {this.ecRep = value;}

}

at the moment of asignig a value to this propery its raises error:

{Cannot evaluate expression because the current thread is in a stack
overflow state.}

thanks for help in advance



Mar 23 '06 #4

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

Similar topics

2
by: Russell Mangel | last post by:
I am trying to create a property which returns an enum. The following class does not work, can someone fix it? I am using VS2003 C++ public __gc class Drive { public: Drive(){} __property...
5
by: Alex Stevens | last post by:
Hi All, In the absence of any predefined standards, I was wondering how to name and implement my enum in a class. My dilema is: When I (for example) have an integer property in my class...
6
by: Bob | last post by:
It should be simple, but I'm stuck on this one... how do you return a value for an enum property type? TIA, Bob
3
by: Frank | last post by:
Hello, question about the values for a property. I have a class with an enum and property: classA public enum x as short a b c end enum
62
by: djake | last post by:
Someone can explain me why to use property get and property set to access a value in a class, insted of access the value directly? What's the usefulness of property statements in VB.NET? Thanks
16
by: David Gacek | last post by:
Anyone know how to ... make a user control property that shows up in the property pages and allows one to select a value from a set of values ? like a combobox for example ?
3
by: Arnold Schrijver | last post by:
I wrote a program that draws items to the screen and maintains a set of Offset values. There was a bug in the code, because objects were positioned wrongly. While debugging I found some peculiar...
0
by: student | last post by:
In Summary: Create an object - dont set one of its Enum Type properties and make sure it does not appear in XML Object Serialization. Strings function as hoped for but Enums do not Heres my...
4
by: Pritcham | last post by:
Hi all I've got a number of classes already developed (basic entity classes) like the following: Public Class Contact Private _firstname as String Private _age as Integer Public Property...
6
by: Rick | last post by:
Hi group, I'm trying to inherit from the windows checkbox control. This is no problem. My goal is to add a property that is based on an enum. When I have an enum declared within the class, it...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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?
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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.