带有引用参数的c# Web服务
本文关键字:Web 服务 参数 引用 | 更新日期: 2023-09-27 18:07:42
我必须创建一个c# web服务我有一个问题。是否可以使用ref
参数?例如,我有这个方法
//my web service will fill the parameter by reference
int myWSMethod(int parameterA, ref string parameterB);
这对于web服务是可能的吗?
如果您的问题只是试图找出如何从web服务返回多个值,只需返回一个复杂的类型,而不是。
[DataContract]
[Serializable]
public class myWSMethodResponse
{
[DataMember]
public int ErrorCode { get; set; }
[DataMember]
public string Report { get; set; }
}
public myWSMethodResponse myWSMethod(int parameterA)
{
//code here
}
我不知道你为什么要这样做,但是基于MSDN,你可以这样做。
Out
和Ref
参数.在大多数情况下,您可以使用In参数(Visual Basic中的
ByVal
)和out
和ref
参数(Visual Basic中的ByRef
)。因为out
和ref
参数都表示该数据从操作返回,操作签名如下所示指定即使操作签名返回void
,也需要一个请求/应答操作。例子:
[ServiceContractAttribute] public interface IMyContract { [OperationContractAttribute] public void PopulateData(ref CustomDataType data); }