111,120
社区成员
发帖
与我相关
我的任务
分享i--
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace WindowsApplication250
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
List<A> X = new List<A>(new A[]
{
new A(1,"a"),
new A(2,"b"),
new A(3,"c")
});
List<A> Y = new List<A>();
foreach (A a in X)
if (a.NO != 2)
Y.Add((A)a.Clone());
}
}
class A : ICloneable
{
public int NO;
public String Name;
public A(int NO, String Name)
{
this.NO = NO;
this.Name = Name;
}
public object Clone()
{
return new A(NO, Name);
}
}
}