Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to deal with System.Drawing.Color <--> System.Windows.Media.Color ambiguous reference

Tags:

c#

.net

I'm using System.Drawing to fill rectangles and draw lines and stuff. The System.Drawing.Color object only has a list of pre-defined colors, and I want to assign my own colors using RGB. So I've added the System.Windows.Media namespace, and now all references to "Color" say they're a ambiguous references.

I understand why. But I am wondering if there is a better solution than doing this

System.Windows.Media.Color colorVariableName;

wherever I reference a Color variable.

like image 345
Almo Avatar asked Dec 12 '25 15:12

Almo


1 Answers

You're able to alias your usings at the top, so you can say something like

using MediaColor = System.Windows.Media.Color

And you'll be able to say

MediaColor colorVariableName
like image 125
Mike M. Avatar answered Dec 14 '25 07:12

Mike M.



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!