Is there any way I can put Public Properties on a single line in VB.NET like I can in C#? I get a bunch of errors every time I try to move everything to one line.
C#:
public void Stub{ get { return _stub;} set { _stub = value; } }
VB.NET
Public Property Stub() As String
Get
Return _stub
End Get
Set(ByVal value As String)
_stub = value
End Set
End Property
Thanks
EDIT: I should have clarified, I'm using VB 9.0.
You can use automatically implemented properties in both VB 10 and C#, both of which will be shorter than the C# you've shown:
public string Stub { get; set; }
Public Property Stub As String
For non-trivial properties it sounds like you could get away with putting everything on one line in VB - but because it's that bit more verbose, I suspect you'd end up with a really long line, harming readability...
Yes you can
Public Property Stub() As String : Get : Return _stub : End Get : Set(ByVal value As String) :_stub = value : End Set : End Property
and you can even make it shorter and not at all readable ;-)
Public Property Stub() As String:Get:Return _stub:End Get:Set(ByVal value As String):_stub = value:End Set:End Property
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With