首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > C# >

怎样在接口类里定义集合,请路过的朋友帮忙,谢谢!

2013-01-18 
怎样在接口类里定义集合,请路过的朋友帮忙,多谢!!!代码如下:请各位帮忙???using Systemusing System.Coll

怎样在接口类里定义集合,请路过的朋友帮忙,多谢!!!
代码如下:请各位帮忙???
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace SerializerTeset.CommonClass
{
    public interface ISerializerObject
    {
        string UserName
        {
            set;
            get;
        }
        string UserId
        {
            set;
            get;
        }

        List<string> LUserName = new List<string>();//想定义这样一个list,系统提示接口里不能有字段,请问高手怎样在接口类里面定义集合????        bool Save(string fileName);
        bool Load(string fileName);
    }
} list interface
[解决办法]

public List<string> LUserName { get; set; }

[解决办法]
 public interface ISerializerObject
    {
        string UserName
        {
            set;
            get;
        }
        string UserId
        {
            set;
            get;
        }

        List<string> LUserName
        {
           set;
           get;
        }
        bool Load(string fileName);
    }
[解决办法]
呵呵,提示不是告诉你的很明白嘛,不能有字段,自然就是可以有属性

按属性方式定义即可

List<string> LUserName{get;set;}//的对于引用对象通常一个get即可,set可有可无,你自己看情况办

热点排行