VB.NET 等效于 C# 属性速记? [英] VB.NET equivalent of C# property shorthand?

查看:23
本文介绍了VB.NET 等效于 C# 属性速记?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有与 C# 等效的 VB.NET:

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

public string FirstName { get; set; }

我知道你可以做到

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

但我似乎无法在 Visual Basic 速记中找到答案.

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

推荐答案

Visual Studio 2008 或之前版本的 VB.NET 没有简写.

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

在 Visual Studio 2010 及更高版本中,您可以使用以下简写:

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

public property FirstName as String

这将按照您在 C# 中的简短版本进行处理 - 我认为他们称之为自动属性"

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

另见:自动实现的属性 (Visual Basic)

这篇关于VB.NET 等效于 C# 属性速记?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆