I have two data types:
class MyDataType {
public int Id;
private int Field;
public String AnotherFieldOrProperty;
// + there are some methods
}
class MyDataTypeDescriptor {
public int Id;
public String Description;
}
I need to convert List<MyDataType> to List<MyDataTypeDescriptor> such a way:
MyDataTypeDescriptor.Id = MyDataType.Id
MyDataTypeDescriptor.Description = MyDataType.ToString();
I guess C# can do that very easy and fast in just one line of code, but I don’t know how because I’m not familar with such advanced techniques. Would someone help me please?
Thanks
This should do it (where
myDataTypesis yourList<MyDataType>):