J
JDC
Hi all,
Say I have a couple of classes which implement an interface
public interface IDataItem
{
int ID { get; set; }
string Name { get; set; }
}
public class Foo : IDataItem
{
private int id;
public int ID
{
get { return id; }
set { id = value; }
}
private string name;
public string Name
{
get { return name; }
set { name = value; }
}
}
public class Bar: IDataItem
{
private int id;
public int ID
{
get { return id; }
set { id = value; }
}
private string name;
public string Name
{
get { return name; }
set { name = value; }
}
}
And I have a method that I want to use for Lists of both classes:
public void DoSomething(List<IDataItem> items)
{
foreach (IDataItem item in items)
}
Say I have a couple of classes which implement an interface
public interface IDataItem
{
int ID { get; set; }
string Name { get; set; }
}
public class Foo : IDataItem
{
private int id;
public int ID
{
get { return id; }
set { id = value; }
}
private string name;
public string Name
{
get { return name; }
set { name = value; }
}
}
public class Bar: IDataItem
{
private int id;
public int ID
{
get { return id; }
set { id = value; }
}
private string name;
public string Name
{
get { return name; }
set { name = value; }
}
}
And I have a method that I want to use for Lists of both classes:
public void DoSomething(List<IDataItem> items)
{
foreach (IDataItem item in items)
}