473,465 Members | 1,651 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

accuracy of warning?

Hi,

I've created a console app in VB.NET 2005 that consists of :

Sub Main()
Dim x As DateTime
x = x.Now

End Sub

I get the following warning:
Access of shared member, constant member, enum member or nested type through
an instance; qualifying expression will not be evaluated.

The warning itself makes sense mostly. There's no reason for me to use an
object instance to access a shared member. However, it states that the
qualifying expression will not be evaluated. This does not seem to be the
case. I get an accurate result with this code; the same result I get with x =
datetime.now . Is this warning inaccurate? Also, what is the harm in using an
object to access a shared member? If you've already got a datetime variable
for whatever reason, why is it discouraged to use it rather than the datetime
type to access the 'now' property?

-Ben
Dec 30 '05 #1
3 4335
It means that 'x' is really ignored. It doesn't actually try to go get the
object that 'x' is pointing to.

The reason it is discouraged, is because the compiler is going to treat it
as if you had said DateTime.Now anyway. Putting a variable name there just
makes it more confusing to read, because it seems like the object that the
variable is pointing to is important, that having 'x' instead of 'y' there
could make a difference - which it would not.

"Ben R." <be**@newsgroup.nospam> wrote in message
news:C8**********************************@microsof t.com...
Hi,

I've created a console app in VB.NET 2005 that consists of :

Sub Main()
Dim x As DateTime
x = x.Now

End Sub

I get the following warning:
Access of shared member, constant member, enum member or nested type
through
an instance; qualifying expression will not be evaluated.

The warning itself makes sense mostly. There's no reason for me to use an
object instance to access a shared member. However, it states that the
qualifying expression will not be evaluated. This does not seem to be the
case. I get an accurate result with this code; the same result I get with
x =
datetime.now . Is this warning inaccurate? Also, what is the harm in using
an
object to access a shared member? If you've already got a datetime
variable
for whatever reason, why is it discouraged to use it rather than the
datetime
type to access the 'now' property?

-Ben

Dec 30 '05 #2
Thanks!

-Ben

"Marina" wrote:
It means that 'x' is really ignored. It doesn't actually try to go get the
object that 'x' is pointing to.

The reason it is discouraged, is because the compiler is going to treat it
as if you had said DateTime.Now anyway. Putting a variable name there just
makes it more confusing to read, because it seems like the object that the
variable is pointing to is important, that having 'x' instead of 'y' there
could make a difference - which it would not.

"Ben R." <be**@newsgroup.nospam> wrote in message
news:C8**********************************@microsof t.com...
Hi,

I've created a console app in VB.NET 2005 that consists of :

Sub Main()
Dim x As DateTime
x = x.Now

End Sub

I get the following warning:
Access of shared member, constant member, enum member or nested type
through
an instance; qualifying expression will not be evaluated.

The warning itself makes sense mostly. There's no reason for me to use an
object instance to access a shared member. However, it states that the
qualifying expression will not be evaluated. This does not seem to be the
case. I get an accurate result with this code; the same result I get with
x =
datetime.now . Is this warning inaccurate? Also, what is the harm in using
an
object to access a shared member? If you've already got a datetime
variable
for whatever reason, why is it discouraged to use it rather than the
datetime
type to access the 'now' property?

-Ben


Dec 30 '05 #3
"Ben R." <be**@newsgroup.nospam> schrieb:
I've created a console app in VB.NET 2005 that consists of :

Sub Main()
Dim x As DateTime
x = x.Now

End Sub

I get the following warning:
Access of shared member, constant member, enum member or nested type
through
an instance; qualifying expression will not be evaluated.

The warning itself makes sense mostly. There's no reason for me to use an
object instance to access a shared member. However, it states that the
qualifying expression will not be evaluated. This does not seem to be the
case. I get an accurate result with this code; the same result I get with
x =
datetime.now . Is this warning inaccurate? Also, what is the harm in using
an
object to access a shared member? If you've already got a datetime
variable
for whatever reason, why is it discouraged to use it rather than the
datetime
type to access the 'now' property?


Consider this sample:

\\\
Public Class Foo
Public Function Goo() As Bla
MsgBox("Foo.Goo")
Return New Bla()
End Function
End Class

Public Class Bla()
Public Shared Sub Baz()
MsgBox("Bla.Baz")
End Sub
End Class
....
Dim x As New Foo()
x.Goo().Baz()
///

In the sample above, 'Foo.Goo' won't be called and thus the message box
showing "Foo.Goo" won't be shown.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Dec 30 '05 #4

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

Similar topics

11
by: Michael Lang | last post by:
You'd think that the advantage to extra decimal places in a data type is better accuracy. Well think again. Look at this method and test results: ...
15
by: dkultasev | last post by:
I mean, when I am trying to get result of 1/3 (or smf) it returns 0.33333333334 or something. I understand that result can not be 100% right, but it is it possibly to get more accuracy ?...
1
by: kk_oop | last post by:
Hi. We have some code that was being accessed through Corba. We recently removed the Corba and replaced it with local method calls. This caused the code to break. Our code is filled with...
5
by: Mr Fish | last post by:
Is it possible for me to record floats in a std::stringstream with 100% accuracy? If so how? Here's a little prog that demonstrates how the default ss loses accuracy ...
6
by: Thomas Lumley | last post by:
What does the standard guarantee about the accuracy of eg the trigonometric functions? There is obviously an implementation-dependent upper bound on the accuracy, since the answer is stored in a...
27
by: VK | last post by:
Following the side thread about the time precision in browser at <http://groups.google.com/group/comp.lang.javascript/browse_frm/thread/91b9f3fd90513161/1ea06131c63cfdf0?hl=en#doc_620f160f0cb57c8c>...
2
by: G8 | 8======D | last post by:
Does anybody know the timing accuracy of VB.Net. I remember that in VB.60, one can only trigger an event with time accuracy <10ms. How about VB.Net? Was this improved? I am making a project for...
1
by: coop | last post by:
I'm trying to port a high-accuracy reaction-time gathering application from a RTLinux C implementation into a web-avaliable implementation. We're obviously expecting to lose some accuracy and...
5
by: Sensei | last post by:
Hi again! I am trying to figure a simple example of a program that shows the accuracy differences between float and double types. In particular I'm searching for an operation that works on...
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
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...
1
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...
0
isladogs
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...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.