什么是:=语法的用法? [英] What is the use of the := syntax?

查看:434
本文介绍了什么是:=语法的用法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是一个C#开发人员,负责处理一个VB.NET项目,当我使用ByRef参数调用一个函数时,VS一直试图让我使用:= thingie。

  While reader.Read()
HydrateBookFromReader(reader:= ???)

HydrateBookFromReader函数具有以下签名:

  Public Function HydrateBookFromReader ByRef reader As SqlDataReader)As Book 

为什么intellisense会坚持使用:= construction,并且它是什么?

解决方案

在VB中,:=用于指定命名参数。 b

 联系人(地址:=2020 Palm Ave,姓名:=Peter Evans)

这对指定可选参数特别有用。


I'm a C# developer working on a VB.NET project, and VS keeps trying to get me to use the := thingie when I call a function with a ByRef parameter like so:

While reader.Read()
HydrateBookFromReader(reader:=???)

the HydrateBookFromReader function has the following signature:

Public Function HydrateBookFromReader(ByRef reader As SqlDataReader) As Book

Why does intellisense keep insisting that I use that := construction, and what is it for?

解决方案

In VB, the := is used in specifying named parameters.

Contact(Address:="2020 Palm Ave", Name:="Peter Evans")

This is especially useful for specifying optional parameters.

这篇关于什么是:=语法的用法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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