Generic parameter doesn't fulfull constraint "Object" for "U"

Hi guys,

Not sure if this is in anyway related to [68069 Closed] Generic parameter doesn’t fulfill constraint.

In 7.1.75.1557 - I had the following working:

public delegate void MenuSelectAction(ICoreOptionsMenu optionsMenu, MenuItem menuItem);	
 ...
private Dictionary<int, MenuSelectAction> _menuSelectActions = new Dictionary<int, MenuSelectAction>(); 

In 7.2.77.1621 - I get Generic parameter doesn’t fulfull constraint “Object” for “U”

I can code around it, but just wondering is it a bug or a feature?!!

Thanks,

Darren.

Kind of depends on the platform, you have some more code so I can try it here?

Ah yes sorry, that would help, it is on Android. Just looking back the snipped did not post correctly, maybe because there were < and > in it? - it should read:

private Dictionary<int, MenuSelectAction> _menuSelectActions = new Dictionary <int, MenuSelectAction>();

Thanks,

Darren.

Hello,

I tried to compile the code here with 2 ways. First way is using Dictionary from java.utils namespace and it gave me an error that Dictionary is an abstract class and cannot be instantiated. The second is using Dictionary from sugar.collections namespace, and in that way code compiles absolutely fine (no errors).
That’s my code:

public interface ICoreOptionsMenu
{
}

public delegate void MenuSelectAction(ICoreOptionsMenu optionsMenu, MenuItem menuItem);	

public class MyClass
{
	private Dictionary<int, MenuSelectAction> _menuSelectActions = new Dictionary<int, MenuSelectAction>();
}

What am I missing here? Could you please provide us with a project that shows your error?

Thanks in advance.

Sorry I should have also specified that yes am using sugar.collections. Your example is spot on just minus the generic parameters on the dictionary. I’ll post a new example when I get home next week.

Thanks

Darren