[CS]Cannot Assign Enumeration to Button.Tag in Xamarin.Android Project

  • Thread starter Thread starter Nathan Sokalski
  • Start date Start date
N

Nathan Sokalski

Guest
I have a Xamarin.Android project that contains a Button and a C# enum. I want to assign a value from this enum to the Tag property of the Button (and as you may know, the Tag property is of type Java.Lang.Object). I have the following code:

this.btnReturnToGameOk.Tag = ReturnToGameStatus.AllowNegative;

However, this give the following error:

Cannot implicitly convert type 'ScorePadBlank_Testing.ReturnToGameStatus' to 'Java.Lang.Object'

Isn't anything supposed to be allowed to be converted to an Object? I know that Java.Lang.Object is not exactly the same as .NET's System.Object, but I always thought that the purpose of the Tag property was to be allowed to store any temporary associated data. And an enum is a very basic type (with a very basic underlying type as well). What should I do? Thanks.


Nathan Sokalski njsokalski@hotmail.com http://www.nathansokalski.com/

Continue reading...
 
Back
Top