日期:2014-05-17  浏览次数:21073 次

怎样在接口类里定义集合,请路过的朋友帮忙,多谢!!!
代码如下:请各位帮忙???
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可有可无,你自己看情况办