One option is to pass a delegate into your function: public static void CDB(object objDBDataItem, Action setter) { T data; if (objDBDataItem is System. DBNull) tData = default(T); else tData = (T)objDBDataItem; setter(data); } And call it like this: CDB(DataRow"ID", (int? I) => iValue = i) It's also worth pointing out that the logic you describe to hide DBNull is already provided by System.Data.
DataRowExtensions. Field : iValue = DataRow. Field("ID") Out of curiosity, why don't you like assigning iValue this way?
One option is to pass a delegate into your function: public static void CDB(object objDBDataItem, Action setter) { T data; if (objDBDataItem is System. DBNull) tData = default(T); else tData = (T)objDBDataItem; setter(data); } And call it like this: CDB(DataRow"ID", (int? I) => iValue = i); It's also worth pointing out that the logic you describe to hide DBNull is already provided by System.Data.
DataRowExtensions. Field: iValue = DataRow. Field("ID"); Out of curiosity, why don't you like assigning iValue this way?
Well I want the function to be as simple as possible. I already know that the type of the iValue is int? So I don't want to repeat myself by typing it again.
I mean it will be time consuming to write the type of each property while writing the code. And the compiler should figure it out by its own from the type of iValue. Thanks for the delegate function but I think its more complex then the other solutions :(.
Anyway I think I will go for iValue = CDB(iValue, DataRow"ID"); which is bad for repeating the iValue twice but I think this is the best solution for donkey copy paste :) – Karim Oct 31 '09 at 14:04.
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.