Well, I' surprised by a thing in VB.NET
I have a property GetUniqueID as String in a class and a private member
UniqueID
This property only increment variable UniqueID (UniqueID+=1) and return new
value.
What I noticed is that in debug mode, every time I hover the mouse to a call
to that property in order to see the curent value, actualy the code is
executed and the variable remain changed
This is normal?
I whould espected only to simulte the execution of get block of my property
and return the value not effectively change the value in the class, so
instead having nice ordered ID's I have some much bigger values at every
debug test
What you think?
--
Cheers,
Crirus
------------------------------
If work were a good thing, the boss would take it all from you
------------------------------ 11 1280
"Crirus" <Cr****@datagroup.ro> schrieb Well, I' surprised by a thing in VB.NET I have a property GetUniqueID as String in a class and a private member UniqueID This property only increment variable UniqueID (UniqueID+=1) and return new value. What I noticed is that in debug mode, every time I hover the mouse to a call to that property in order to see the curent value, actualy the code is executed and the variable remain changed
This is normal?
Yes. A property should *always* return the same value when called twice - or
at least it should not return a different value just because of the call
itself. Use a function instead. The name "Get*" already expresses that it is
a function.
--
Armin http://www.plig.net/nnq/nquote.html http://www.netmeister.org/news/learn2quote.html
* "Crirus" <Cr****@datagroup.ro> scripsit: Well, I' surprised by a thing in VB.NET I have a property GetUniqueID as String in a class and a private member UniqueID This property only increment variable UniqueID (UniqueID+=1) and return new value. What I noticed is that in debug mode, every time I hover the mouse to a call to that property in order to see the curent value, actualy the code is executed and the variable remain changed
That's a typical case for using a /method/ instead of a property.
Properties are used to model attributes of an entity. Calculating a new
ID is not an attribute, it's a thing the object can do (implemented as a
method).
\\\
Public Function GetUniqueId() As Integer
UniqueID = UniqueID + 1
Return UniqueID
End Function
///
--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>
I was thinking on executing but not modifying the data
--
Cheers,
Crirus
------------------------------
If work were a good thing, the boss would take it all from you
------------------------------
"Armin Zingler" <az*******@freenet.de> wrote in message
news:%2*****************@TK2MSFTNGP11.phx.gbl... "Crirus" <Cr****@datagroup.ro> schrieb OK, I can work around that, but is normal?
Yes
I think not, a debug call as a warch shouldnt execute anything in the same scope as programm itself, right?
It must execute the code. How else should it get the property value?
-- Armin
http://www.plig.net/nnq/nquote.html http://www.netmeister.org/news/learn2quote.html
No what I meant was kind of "simulating" the code execution in order to give
me the correct value, but without retaining in the real code the value
returned, so each time I hover the mouse on a property call, to see the same
value as the excution thread will get first time
--
Cheers,
Crirus
------------------------------
If work were a good thing, the boss would take it all from you
------------------------------
"Armin Zingler" <az*******@freenet.de> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl... "Crirus" <Cr****@datagroup.ro> schrieb I was thinking on executing but not modifying the data
Executing what? I thought _you_ are modifying the data in the property get procedure.
-- Armin
http://www.plig.net/nnq/nquote.html http://www.netmeister.org/news/learn2quote.html
"Crirus" <Cr****@datagroup.ro> schrieb No what I meant was kind of "simulating" the code execution in order to give me the correct value, but without retaining in the real code the value returned, so each time I hover the mouse on a property call, to see the same value as the excution thread will get first time
Well, it doesn't work this way (I can't imagine how it could). To get the
property value the property-get procedure is called. Sorry, there's nothing
more I can say.
--
Armin http://www.plig.net/nnq/nquote.html http://www.netmeister.org/news/learn2quote.html
Yes but any watch will comnpromise the real value that should be returned by
the property as if I dont wach it :(
--
Cheers,
Crirus
------------------------------
If work were a good thing, the boss would take it all from you
------------------------------
"Armin Zingler" <az*******@freenet.de> wrote in message
news:uW****************@tk2msftngp13.phx.gbl... "Crirus" <Cr****@datagroup.ro> schrieb No what I meant was kind of "simulating" the code execution in order to give me the correct value, but without retaining in the real code the value returned, so each time I hover the mouse on a property call, to see the same value as the excution thread will get first time Well, it doesn't work this way (I can't imagine how it could). To get the property value the property-get procedure is called. Sorry, there's
nothing more I can say.
-- Armin
http://www.plig.net/nnq/nquote.html http://www.netmeister.org/news/learn2quote.html
I will :)
--
Cheers,
Crirus
------------------------------
If work were a good thing, the boss would take it all from you
------------------------------
"Armin Zingler" <az*******@freenet.de> wrote in message
news:Oj**************@TK2MSFTNGP12.phx.gbl... "Crirus" <Cr****@datagroup.ro> schrieb Yes but any watch will comnpromise the real value that should be returned by the property as if I dont wach it :( It is your mistake that you change the value. As already mentioned, you
must use a function instead.
-- Armin
http://www.plig.net/nnq/nquote.html http://www.netmeister.org/news/learn2quote.html This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: ss |
last post by:
Hi
I built an exe in console debug mode & Release mode . The console
debug mode -exe works fine ...but the release mode EXE starts well but
fails mid way .
The exe is being started as a...
|
by: marcus |
last post by:
I have this class A that contains a method A_method that opens a file
and does fgets.
I also have a template class B that contains a method B_method that
takes a class A object as template type....
|
by: |
last post by:
Hi,
does anyone know what would be the (most common) reasons
to get difference answers in VC++.net between running in
release and debug ?
Thanks,
JC
|
by: Tom |
last post by:
How can I make code not execute for a debug build, but do
execute for a production build?
I have code which prompts for an account and password when
the program starts up. It is a pain to have to...
|
by: moondaddy |
last post by:
I have a website where cataloge pages are populated by calling a stored
procedure on sql server. I use the sql data adapter's fill method to call
this stored procedure and fill the dataset. about...
|
by: rocketman768 |
last post by:
Hi. I'm just trying to compile a program here, but when I run the
program, I get debug output like:
6192: symbol=printf; lookup in file=/lib/tls/i686/cmov/libc.so.6
when I'm trying to...
|
by: semedao |
last post by:
Hi , I am using asyc sockets p2p connection between 2 clients.
when I debug step by step the both sides , i'ts work ok.
when I run it , in somepoint (same location in the code)
when I want to...
|
by: BA |
last post by:
I posted on this once before and could not get a solution, I am hoping
someone can help. I have a very strange code debug behavior that I cannot
make heads or tails of:
I have c# code being...
|
by: ToadLurker |
last post by:
Usually, to debug my .NET dll, I typically just run my web application
until the DLL in question is invoked - at which point I can just
attach to it via Visual Studio .Net, and debug it. Two weeks...
|
by: Dave Johansen |
last post by:
I just converted a solution from Visual Studio 2003 to Visual Studio
2005 and the Debug mode seems to be running just fine, but the Release
mode crashes on the following code:
std::ifstream...
|
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...
|
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...
|
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,...
|
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...
|
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...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
| |