Convert generic type to another generic type extension method?

If the method is generic, it should include all generic types, including TTypeConvertTo You probably don't need TTypeConvertFrom as a generic type, so try: public static List ConvertFromEntityContext (this List source) If you need both types to be generic (which doesn't really seem necessary), you also have to have TTypeConvertFrom constrained to a base type that has the method ConvertFromEntityContext : public static List ConvertFromEntityContext (this List source) where TTypeConvertTo : BaseModel, TTypeConvertFrom : FromBaseModel That is less advisable, as it will make the call overly verbose: the compiler cannot infer the return type, so you'll have to specify both types every time you call the method Either way, you can use LINQ to rewrite the body of your method: if (source == null) return null; return source. Select(item => item. ConvertFromEntityContext()).ToList().

If the method is generic, it should include all generic types, including TTypeConvertTo. You probably don't need TTypeConvertFrom as a generic type, so try: public static List ConvertFromEntityContext (this List source) If you need both types to be generic (which doesn't really seem necessary), you also have to have TTypeConvertFrom constrained to a base type that has the method ConvertFromEntityContext: public static List ConvertFromEntityContext (this List source) where TTypeConvertTo : BaseModel, TTypeConvertFrom : FromBaseModel That is less advisable, as it will make the call overly verbose: the compiler cannot infer the return type, so you'll have to specify both types every time you call the method. Either way, you can use LINQ to rewrite the body of your method: if (source == null) return null; return source.

Select(item => item. ConvertFromEntityContext()).ToList().

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.

Related Questions