WCF 中的“by ref"参数是好是坏? [英] Are 'by ref' arguments in WCF bad or good?

查看:23
本文介绍了WCF 中的“by ref"参数是好是坏?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近看到一个 WCF 服务声明带有 by ref 参数的操作契约.

I've recently seen a WCF service declaring operation contracts with by ref arguments.

我不知道为什么会做出这个设计决定(操作无效),但此外,根据我的 WCF 知识,我无法确定这是否是一个好的做法.或者如果这不相关.

I don't know why this design decision was taken (operations are void), but furthermore, I'm not able - from my WCF knowledge - to say if this is a good practice or not. Or if this is not relevant.

你怎么看?

推荐答案

但是,根据这篇 Microsoft 文章,WCF 调用的行为与远程过程调用完全相同,并且 ByRef 参数可用于返回数据:-

However, According to this Microsoft Article a WCF Call behaves exactly like a Remote Procedure Call and ByRef arguments can be used to return data:-

http://msdn.microsoft.com/en-us/library/ms733070.aspx

参考章节:输出和参考参数

Refer to the section: Out and Ref Parameters

在大多数情况下,您可以使用 in 参数(Visual Basic 中的 ByVal)和out 和 ref 参数(Visual Basic 中的 ByRef).因为无论是外出还是ref 参数表示数据是从一个操作中返回的,一个如下所示的操作签名指定一个请求/回复操作是必需的,即使操作签名返回无效.

In most cases, you can use in parameters (ByVal in Visual Basic) and out and ref parameters (ByRef in Visual Basic). Because both out and ref parameters indicate that data is returned from an operation, an operation signature such as the following specifies that a request/reply operation is required even though the operation signature returns void.

这篇关于WCF 中的“by ref"参数是好是坏?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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