Store a color in SQL database

Hello,

I have a problem with ToArgb() Method in Xamarin...

I need to convert a color to int32 and store it in a SQL database, but the method ToArgb is not working...

Any Sugestion??

Best Answer

Answers

  • ClintStLaurentClintStLaurent USUniversity ✭✭✭✭✭

    What do you mean by "not working" ?
    What do you get as a returned result?
    A screen shot of Visual Studio showing the values/watch palette during the breakpoint would help a ton.

  • JohnHardmanJohnHardman GBUniversity mod

    @Enrique4to said:
    I need to convert a color to int32 and store it in a SQL database, but the method ToArgb is not working...

    The answer from @LandLu is correct.

    However, the question is whether you should be storing color information in the database. In most situations the answer is no. For example:

    (1) if a particular color is used to represent a state (e.g. valid/invalid, love/like/dislike/hate etc), you should store the state in the database, not the color, and then have your ViewModel or a ValueConverter in your View, convert between the state and the color.

    (2) if you are storing colors configured by a particular user for their local device, you would normally store those colors in settings (e.g. using Xamarin.Essentials) rather than in a SQL database.

    Of course, there are situations where storing color information in a SQL database is appropriate, and for those situations the answer from @LandLu is appropriate.

Sign In or Register to comment.