Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why doesn't VB.NET 9 have Automatic Properties like C# 3?

Would having a nice little feature that makes it quicker to write code like Automatic Properties fit very nicely with the mantra of VB.NET?

Something like this would work perfect:

Public Property FirstName() As String
    Get
    Set
End Property

UPDATE: VB.NET 10 (coming with Visual Studio 2010 and .NET 4.0) will have Automatic Properties. Here's a link that shows a little info about the feature: http://geekswithblogs.net/DarrenFieldhouse/archive/2008/12/01/new-features-in-vb.net-10-.net-4.0.aspx

In VB.NET 10 Automatic Properties will be defines like this:

Public Property CustomerID As Integer
like image 687
Chris Pietschmann Avatar asked Sep 23 '08 17:09

Chris Pietschmann


People also ask

Why we use properties in C# instead of fields?

In almost all cases, fields should be private. Not just non-public, but private. With automatic properties in C# 3, there's basically no cost in readability or the amount of code involved to use a property instead of a field.

What is auto implemented property?

Auto-implemented properties enable you to quickly specify a property of a class without having to write code to Get and Set the property.

What are properties vb net?

A property is a value or characteristic held by a Visual Basic object, such as Caption or Fore Color. Properties can be set at design time by using the Properties window or at run time by using statements in the program code. Object.

What is get and set property in VB net?

In properties, the Get accessor is useful to return the property value and the Set accessor is useful to assign a new value. The value keyword in Set accessor is useful to define the value which is going to be assigned by the Set accessor.


1 Answers

One reason many features get delayed in VB is that the development structure is much different than in C# and additionally, that often more thought goes into details. The same seems to be true in this case, as suggested by Paul Vick's post on the matter. This is unfortunate because it means a delay in many cases (automatic properties, iterator methods, multiline lambdas, to name but a few) but on the other hand, the VB developers usually get a much more mature feature in the long run (looking at the discussion, this will be especially true for iterator methods).

So, long story short: VB 10 will (hopefully!) see automatic properties.

like image 142
Konrad Rudolph Avatar answered Oct 11 '22 14:10

Konrad Rudolph