People is a dictionary, usingPeople clonedPeople=new People(MyContent.val);will not give your a deeply cloned object, you probably should do (what is the MyContent stuff??)People clonedPeople=new People(MyContent.val);foreach (DictionaryEntry de in this)
{
clonedPeople.Add(de.Key, de.Value);
}return clonedPeople;
{
clonedPeople.Add(de.Key, de.Value);
}return clonedPeople;
解决方案 »
- datagridview绑定数据源后插入行
- C#调用C++ DLL接口参数的问题(参数与指针相关)
- 请教 winform Button控件几个属性 ?
- 打开同一个form多次的问题
- c# 中richtextbox 中撤销操作
- 如何生成同时复制程序集
- ~~~~急~~~~网页上的TextBox 和 CheckBox
- 在datagrid中如何使定位的行自动滚动到可见界面上?
- 错误的完全描述,希望大家帮忙,1935错误
- 拷贝内存时出现的问题!
- ParameterDirection.InputOutput 单独in或者out明白,为什么in和out组合? [Serializable]是可以指定任意的类?
- 请问如何用c#实现针对文件读取更改添加删除属性的摘要,最好有代码,强烈谢谢
我在我的code中加了你的代码后,调试出错:
J:\learnvc#\my\chap11\people\people.cs(99): 与“people.People.Add(string, people.Person)”最匹配的重载方法具有一些无效参数
J:\learnvc#\my\chap11\people\people.cs(99): 参数“1”(参数1为de.Key) : 无法从“object”转换为“string”
J:\learnvc#\my\chap11\people\people.cs(99): 参数“2”(参数2为de.Value) : 无法从“object”转换为“people.Person”MyContent是我仿照书上的写法写的,我不知道这儿该如何实现深度复制,试着写的......
{
clonedPeople.Add((String)de.Key, (Person)de.Value);
}
http://www.codeproject.com/dotnet/Clone.aspBase class for cloning an object in C#
http://www.codeproject.com/csharp/cloneimpl_class.asp