Tag Archives: nhibernate

The type arguments for method cannot be inferred from the usage…

I created a helper method to iterate a list of strongly typed objects.  It was to be a simple method, that just returning a property of the objects with a separator character between each.  The method signature looked like the following:

public static string FormatMyList<T>(List<T> list, string separator)
{ … }

 
What I had overlooked, though, was that the property I was passing was only an IList object (due to being a property used with nHibernate).  So, I received an error message similar to the following: Compiler Error Message: CS0411:
The type arguments for method ‘TextFormatUtil.FormatMyList<T>(System.Collections.Generic.List<T>)’
cannot be inferred from the usage. Try specifying the type arguments
explicitly.

After correcting the method signature to use an IList, everything was fine…