You could use an object that provides the conversion on a DataRow to your type : public interface IDataRowConverter { T Convert(DataRow row); } Provide your custom converter to your function : public static T ConvertToArray(DataTable dataTable, IDataRowConverter converter) { List result = new List(); foreach (DataRow dataRow in dataTable. Rows) result. Add(converter.
Convert(dataRow)); return result.ToArray(); } Then, implement the interface for your needed type : public class MyObjectDataRowConverter : IDataRowConverter { public MyObject Convert(DataRow row) { MyObject myObject = new MyObject(); // Initialize object using the row instance return myObject; } } You can then call your function using this code : MyObject objectArray = ConvertToArray(datatable, new MyObjectDataRowConverter()).
They look like this: public static implicit operator Posting(DataRow dataRow) { // something that retusn a Posting object } – Olle May 11 '10 at 9:49 If you want to use a generic implementation, any operation you want to use must be defined on the generic type. You cannot use the operator in your function when working with the generic implementation as . Net does not allow operator constraints.
However, using the described method, you can use the operator when implementing your Converter class. – Thibault Falise May 11 '10 at 10:53 Ok, many thanks! I will have to do it that way then.
Thanks! – Olle May 11 '10 at 12:01.
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.