调试行为 [英] Debug behavior

查看:75
本文介绍了调试行为的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

好吧,我对VB.NET中的一件事感到惊讶

我在类中有一个属性GetUniqueID作为String,私有成员

UniqueID

此属性仅增加变量UniqueID(UniqueID + = 1)并返回新的

值。

我注意到在调试模式下,每次我悬停鼠标给那个属性打电话

以查看当前值,实际代码是执行
并且变量保持不变


这是正常的吗?


我只会想到同时执行我的财产的get block

并且返回值不能有效地改变在课堂上的价值,所以

而不是有良好的有序ID'我在每个

调试测试中都有一些更大的值


你的想法?


-

干杯,

Crirus


------------------------------

如果工作是好事,老板会接受这一切都来自你


------------------------------

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

------------------------------

推荐答案

" Crirus" <铬**** @ datagroup.ro> schrieb
"Crirus" <Cr****@datagroup.ro> schrieb
好吧,我对VB.NET中的一个东西感到惊讶
我在类中有一个属性GetUniqueID as String和一个私有
成员UniqueID
这个属性只增加变量UniqueID(UniqueID + = 1)和
返回新值。
我注意到,在调试模式下,每次我将鼠标悬停在
按顺序调用该属性要查看当前值,实际执行代码并且变量保持不变

这是正常的吗?
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?




是的。一个属性应该*总是*在被调用两次时返回相同的值 - 或者

至少它不应该因为调用

本身而返回不同的值。请改用功能。名称Get *已经表示它是

a功能。

-

Armin

http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html



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


还包括调试问题:
http://groups.google.com/groups?selm...tngp13.phx.gbl


;-)

-

Armin

Also including the debugging issue:
http://groups.google.com/groups?selm...tngp13.phx.gbl

;-)

--
Armin


* " Crirus" <铬**** @ datagroup.ro> scripsit:
* "Crirus" <Cr****@datagroup.ro> scripsit:
嗯,我对VB.NET中的一个东西感到惊讶
我在一个类和一个私有成员中有一个属性GetUniqueID作为String
UniqueID
此属性仅增加变量UniqueID(UniqueID + = 1)并返回新的值。
我注意到的是,在调试模式下,每次我将鼠标悬停在对该属性的调用中为了看到curent值,实际执行代码并且变量保持不变
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




这是使用/ method /的典型案例属性。

属性用于建模实体的属性。计算一个新的

ID不是属性,它是对象可以做的事情(实现为

方法)。


\\\

公共函数GetUniqueId()As Integer

UniqueID = UniqueID + 1

返回UniqueID

结束功能

///


-

Herfried K. Wagner [MVP]

< http://www.mvps.org/dotnet>



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>


这篇关于调试行为的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆