public MapPoint Copy()//MapPoint克隆方法 { MapPoint p = new MapPoint();//这是我自定义的对象 //利用反射获得类成员 FieldInfo[] fieldFroms = IntrospectionExtensions.GetTypeInfo(p.GetType()).DeclaredFields.ToArray(); FieldInfo[] fieldTos = IntrospectionExtensions.GetTypeInfo(this.GetType()).DeclaredFields.ToArray(); int lenTo = fieldTos.Length; for (int i = 0, l = fieldFroms.Length; i < l; i++) { for (int j = 0; j < lenTo; j++) { if (fieldTos[j].Name != fieldFroms[i].Name) continue; fieldTos[j].SetValue(p, fieldFroms[i].GetValue(this));
break; } } return p; }