带有引用参数的 C# Web 服务

标签 c# web-services visual-studio pass-by-reference

我必须创建一个 C# 网络服务。我有个问题。可以使用 ref 参数吗? 比如我有这个方法

//my web service will fill the parameter by reference
int myWSMethod(int parameterA, ref string parameterB);

这可以通过网络服务实现吗?

最佳答案

如果您的问题只是想弄清楚如何从 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
}

关于带有引用参数的 C# Web 服务,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15819492/

相关文章:

java - 使用 Metro 编码 JAXB 类时忽略 schemaLocation

visual-studio - Visual Studio 2008 ASMX文件

visual-studio - 在许多 VS 解决方案上自动执行 nuget 更新包操作

c# - 如何用不同的默认值初始化多维数组

c# - View 模型之间的绑定(bind)属性

c# - 在不同的远程机器上使用 StateServer 模式时出现问题

jquery - 仍然收到 "Request format is unrecognized for URL unexpectedly ending in..."

php - PHP 类的版本控制

c# - 当我尝试使用 visual c# 连接 SQL Server 时收到此错误消息

c++ - "static enum"在 C++ 中是什么意思?