VB.NET equivalent of C# property shorthand?

Birk picture Birk · Jan 20, 2009 · Viewed 61.2k times · Source

Is there a VB.NET equivalent to the C#:

public string FirstName { get; set; }

I know you can do

Public Property name() As String
   Get
      Return _name.ToString
   End Get
   Set(ByVal value As String)
       _name = value
   End Set
End Property

But I can't seem to google up an answer on a Visual Basic shorthand.

Answer

Stefan picture Stefan · Jan 20, 2009

There is no shorthand for Visual Studio 2008 or prior for VB.NET.

In Visual Studio 2010 and beyond, you can use the following shorthand:

public property FirstName as String

This will be handled as your short version in C# is - I think they call it "Auto Property"

See also: Auto-Implemented Properties (Visual Basic)