Re: I don't like this behavior - implicitly returning value types
- From: "Brian Gideon" <briangideon@xxxxxxxxx>
- Date: 31 Jan 2007 06:28:00 -0800
On Jan 30, 2:02 pm, "rowe_newsgroups" <rowe_em...@xxxxxxxxx> wrote:
I just noticed this about value types and return values, and it kind
of bugs me that the compiler won't treat it as an error, even with
Option Strict On.
Try this out:
Option Strict On
Public Class MyClass
Private Sub ExtractionSettings_Load(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
MsgBox(MyProp.ToString())
End Sub
ReadOnly Property MyProp() As Int16
Get
End Get
End Property
End Class
This will compile and run perfectly fine (if I typed it right :-) ),
always showing 0 in the opening messagebox. I really wish that the IDE
would tell me that I didn't explicitly specify a return value for
MyProp. (Yes, I know it's a value type and therefore it has a value of
0 at instantiation so it is returning a value, and thus not violating
the return value rules).
Is there a setting I missed somewhere that I could use to flag this as
an error?
Thanks,
Seth Rowe
Seth,
I wonder if it's like that to keep as much compatibility with VB6 as
possible. Though, you'd think a warning would be an acceptable
compromise.
Brian
.
- References:
- I don't like this behavior - implicitly returning value types
- From: rowe_newsgroups
- I don't like this behavior - implicitly returning value types
- Prev by Date: Re: amend a control by function or class
- Next by Date: Re: I don't like this behavior - implicitly returning value types
- Previous by thread: Re: I don't like this behavior - implicitly returning value types
- Next by thread: taking a very very long time to build a small project
- Index(es):
Relevant Pages
|