VB.NET equivalent of C# property shorthand?

C#vb.netLanguage Features

C# Problem Overview


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.

C# Solutions


Solution 1 - C#

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)

Solution 2 - C#

In Visual Studio 2008, after typing just the keyword Property, press the Tab key. It'll paste a template snippet for you which you can fill very quickly.

But yeah, there is not a replacement of a Visual Basic 10-type shortcut in Visual Basic 9.

Solution 3 - C#

Unfortunately, Visual Basic 9 (which ships with .NET 3.5/Visual Studio 2008) does not have automatic properties.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionBirkView Question on Stackoverflow
Solution 1 - C#StefanView Answer on Stackoverflow
Solution 2 - C#AliView Answer on Stackoverflow
Solution 3 - C#Jon LimjapView Answer on Stackoverflow