命名空间[DataContract] [英] Namespace for [DataContract]

查看:921
本文介绍了命名空间[DataContract]的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我无法找到用于 [DataContract] [数据成员] 元素的名称空间。据我发现,似乎加入以下应该是足够了,但对我来说不是。

I can't find the namespace to use for [DataContract] and [DataMember] elements. According to what I've found, it seems that adding the following should be enough, but in my case it is not.

using System;
using System.Runtime.Serialization;

下面是我的code的一个片段:

Here is a snippet of my code:

using System;
using System.Runtime.Serialization;

namespace MyNamespace {

    [DataContract]
    public class Tuple<T1, T2> {
            // A custom implementation of a Tuple
            //...
            //...
        }
}

和错误,我得到:

类型或命名空间名称'DataContract'找不到(是否缺少using指令或程序集引用?)

The type or namespace name 'DataContract' could not be found (are you missing a using directive or an assembly reference?)

我不是使用正确的命名空间?

Am I not using the right namespaces?

推荐答案

DataContractAttribute 类是在 System.Runtime.Serialization 命名空间。

但你要添加引用 System.Runtime.Serialization.dll

这篇关于命名空间[DataContract]的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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