我有两个数据类型:如何将List <SomeType>转换为列表<AnotherType>?
class MyDataType {
public int Id;
private int Field;
public String AnotherFieldOrProperty;
// + there are some methods
}
class MyDataTypeDescriptor {
public int Id;
public String Description;
}
我需要转换List<MyDataType>
到List<MyDataTypeDescriptor>
这样一种方式: MyDataTypeDescriptor.Id = MyDataType.Id
MyDataTypeDescriptor.Description = MyDataType.ToString()
;
我想C#可以在一行代码中非常简单快速地完成,但是我不知道如何,因为我不熟悉这种高级技术。请有人帮助我吗?
感谢