我有一个包含结构作为键的字典,我必须为字典创建一个属性
项目1
namespace ClassLibrary2
{
public class Class1
{
public Dictionary<string, Cs> mdic;
public Class1()
{
mdic = new Dictionary<string, Cs>();
mdic.Add("Welcome", new Cs() { m1 = "12",m2="32"});
}
public Dictionary<string, Cs> Dic
{
get {return mdic;}
set { value = mdic; }
}
public struct Cs
{
public string m1{get;set;}
public string m2{get;set;}
}
}
当我尝试设置此值时,project 1
它显示错误...
像这样我设置
项目2
namespace WindowsFormsApplication20
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private Dictionary<string, Cs> Dic
{
get;
set;
}
struct Cs
{
public string m1 { get; set; }
public string m2 { get; set; }
}
private void button1_Click(object sender, EventArgs e)
{
ClassLibrary2.Class1 css = new ClassLibrary2.Class1();
Dic = css.Dic;
}
}
我有问题 css.Dic
..... System Generic Collections