The following code Resharper gives me a warning: Cannot cast expression of type 'Color' to type 'UIntPtr'. (In fact, Resharper considers this a factual error.)
However, the compiler does not warn and works fine.
It looks like a Resharper bug for me. It? Or is there something bad about this that the compiler is not worried about? (I am using Resharper 7.1.1)
using System;
namespace Demo
{
internal class Program
{
public enum Color { Red, Green, Blue }
private static void Main(string[] args)
{
UIntPtr test = (UIntPtr) Color.Red;
}
}
}
I can make a warning by removing the value first in int, so I have a workaround:
UIntPtr test = (UIntPtr)(int) Color.Red;
source
share