什么是使用像这样的枚举的问题? [英] Whats's the problem using a enum like this?
问题描述
如果e.Button = MouseButtons.Left那么
也来自
Dim Answer As DialogResult = MessageBox.Show ..
选择案例答案
Case DialogResult.Yes
和枚举的许多其他用途我获取
警告153通过实例访问共享成员,常量成员,枚举成员或嵌套
类型;资格表达不会被评估。
为什么不呢。使用这样的枚举有什么问题?
If e.Button = MouseButtons.Left Then
also from a
Dim Answer As DialogResult = MessageBox.Show..
Select Case Answer
Case DialogResult.Yes
and many other uses of an enum I get
Warning 153 Access of shared member, constant member, enum member or nested
type through an instance; qualifying expression will not be evaluated.
Why not. What''s the problem using a enum like this?
推荐答案
你确定这是其中一个案例?你在那里的代码不会产生那些类型的警告 - 它不适合我。
" ** **开发" < RE ************* @ a-znet.com>在消息中写道
news:或************** @ TK2MSFTNGP09.phx.gbl ...
Are you sure this is one of those cases? The code you have there wouldn''t
generate those types of warnings - it doesn''t for me.
" **Developer**" <RE*************@a-znet.com> wrote in message
news:Or**************@TK2MSFTNGP09.phx.gbl...
如果e.Button = MouseButtons.Left然后
也来自
Dim Answer As DialogResult = MessageBox.Show ..
选择案例答案
以及我得到的枚举的许多其他用途
警告153访问共享成员,常量成员,枚举成员或
嵌套类型通过一个实例;资格表达不会被评估。
为什么不呢。使用这样的枚举有什么问题?
If e.Button = MouseButtons.Left Then
also from a
Dim Answer As DialogResult = MessageBox.Show..
Select Case Answer
Case DialogResult.Yes
and many other uses of an enum I get
Warning 153 Access of shared member, constant member, enum member or
nested type through an instance; qualifying expression will not be
evaluated.
Why not. What''s the problem using a enum like this?
" ** **开发" < RE ************* @ a-znet.com> schrieb:
" **Developer**" <RE*************@a-znet.com> schrieb:
如果e.Button = MouseButtons.Left那么
也来自
Dim Answer As DialogResult = MessageBox.Show ..
选择案例答案
案例DialogResult.Yes
以及我得到的枚举的许多其他用途
警告153访问共享成员,常量成员,枚举成员或
嵌套类型通过实例;资格表达式不会被评估。
If e.Button = MouseButtons.Left Then
also from a
Dim Answer As DialogResult = MessageBox.Show..
Select Case Answer
Case DialogResult.Yes
and many other uses of an enum I get
Warning 153 Access of shared member, constant member, enum member or
nested type through an instance; qualifying expression will not be
evaluated.
问题是表单有一个''DialogResult''属性,它隐藏了
键入''DialogResult''。完全限定''DialogResult''类型
(''System.Windows.Forms.DialogResult'')或定义名称空间别名:
\\ \\\\
导入WinForms = System.Windows.Forms
....
如果答案= WinForms.DialogResult.OK然后
...
结束如果
///
-
MS Herfried K. Wagner
MVP< URL:http://dotnet.mvps.org/>
VB< URL:http:/ /classicvb.org/petition/>
The problem is that forms have a ''DialogResult'' property which shadows the
type ''DialogResult''. Either fully qualify the ''DialogResult'' type
(''System.Windows.Forms.DialogResult'') or define a namespace alias:
\\\
Imports WinForms = System.Windows.Forms
....
If Answer = WinForms.DialogResult.OK Then
...
End If
///
--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>
**开发人员**,
除了其他评论。
正如您所知,这是一个新的警告,旨在让您知道
可能令人困惑的代码,例如代码:
Dim aThread As New System.Threading.Thread(AddressOf ThreadProc)
aThread.Start()
aThread.Sleep(TimeSpan.FromSeconds(5))
哪个线程要睡5秒钟?
记住Thread.Sleep是一个在CurrentThread上运行的共享方法。
|警告153访问共享成员,常任成员,枚举成员或
嵌套
|通过实例输入;资格表达式不会被评估。
所有153都是指DialogResult?
你可以使用Project - Properties - Compile更改实例
变量访问共享成员从警告到无。但是我只会暂时更改它以简化更改其他错误&警告。一旦
其他错误&警告得到照顾我会重新打开警告&
解决问题...
-
希望这有助于<
Jay [MVP - Outlook]
..NET应用程序架构师,爱好者,&福音传教士
T.S.布拉德利 - http://www.tsbradley.net
" ; ** **开发" < RE ************* @ a-znet.com>在留言中写道
news:或************** @ TK2MSFTNGP09.phx.gbl ...
|如果e.Button = MouseButtons.Left那么
|
|也来自
|
|昏暗的答案As DialogResult = MessageBox.Show ..
|
|选择案例答案
|
| Case DialogResult.Yes
|
|和enum的许多其他用途我得到
|
|警告153访问共享成员,常任成员,枚举成员或
嵌套
|通过实例输入;资格表达不会被评估。
|
|
|
|为什么不。使用这样的枚举有什么问题?
|
|
|
|
|
|
**Developer**,
In addition to the other comments.
As you may this is a new warning that is intended to let you know of
potentially confusing code, such as code like:
Dim aThread As New System.Threading.Thread(AddressOf ThreadProc)
aThread.Start()
aThread.Sleep(TimeSpan.FromSeconds(5))
Which Thread is going to sleep for 5 seconds?
Remember Thread.Sleep is a shared method that operates on the CurrentThread.
| Warning 153 Access of shared member, constant member, enum member or
nested
| type through an instance; qualifying expression will not be evaluated.
Are all 153 referring to DialogResult?
You could use "Project - Properties - Compile" to change the "Instance
variable accesses shared member" from Warning to None. However I would only
change it temporarily to simplify changing other errors & warnings. Once the
other errors & warnings are taken care of I would turn the warning back on &
address the issues...
--
Hope this helps
Jay [MVP - Outlook]
..NET Application Architect, Enthusiast, & Evangelist
T.S. Bradley - http://www.tsbradley.net
" **Developer**" <RE*************@a-znet.com> wrote in message
news:Or**************@TK2MSFTNGP09.phx.gbl...
| If e.Button = MouseButtons.Left Then
|
| also from a
|
| Dim Answer As DialogResult = MessageBox.Show..
|
| Select Case Answer
|
| Case DialogResult.Yes
|
| and many other uses of an enum I get
|
| Warning 153 Access of shared member, constant member, enum member or
nested
| type through an instance; qualifying expression will not be evaluated.
|
|
|
| Why not. What''s the problem using a enum like this?
|
|
|
|
|
|
这篇关于什么是使用像这样的枚举的问题?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!