c# - 如何在 XML-RPC 和 C# 中使用枚举?

标签 c# xml-rpc enumeration

我在 C# 中使用 Cook Computing XMLRPC 框架。我正在调用一个需要 int 的远程函数。我想在客户端代码中使用枚举,而不是仅使用函数参数中硬编码的数字调用函数。

代码编译成功,但在测试期间抛出 XmlRpcUnsupportedTypeException。该消息指出我的枚举无法映射到 XML-RPC 类型。枚举如下:

public enum Codes : int
{
    Installed = 903,
}

我有一种感觉,我忽略了一些简单的东西,但我不能 Handlebars 指放在上面,所以我在这里将我的 Bat 信号发射到云端!

最佳答案

尝试显式转换? (int)已安装

MSDN:

The underlying type specifies how much storage is allocated for each enumerator. However, an explicit cast is necessary to convert from enum type to an integral type. For example, the following statement assigns the enumerator Sun to a variable of the type int by using a cast to convert from enum to int:

int x = (int)Days.Sun;

关于c# - 如何在 XML-RPC 和 C# 中使用枚举?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/638799/

相关文章:

c# - Windows 中公钥和私钥容器的位置?

c# - 从哪里获得线程安全的 Ghostscript 编译?

c# - 尝试将值从文本框分配给变量时出现空异常

python - 如何处理 Python XML-RPC 输出和异常?

android - 有没有人将 ODOO 与 Android 集成?

java - 从 vector 转换为对象数组

swift - 使用 nextObject() 枚举集合没有按预期工作?

c# - 如何在 .Net 中使用 OleDB 以我想要的格式从 CSV 导入值?

c++ - 不同的枚举,相同的值

JAVA Hashtable 查找最大值