Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
The given expression is always of the provided ('type') type
If a conditional statement always evaluates to true, then you do not need a conditional statement. This warning occurs when you try to evaluate a type using the is operator. If the evaluation is a value type, then the check is unnecessary.
The following sample generates CS0183:
// CS0183.cs
// compile with: /W:1
using System;
public class Test
{
public static void F(Int32 i32, String str)
{
if (str is Object) // OK
Console.WriteLine( "str is an object" );
else
Console.WriteLine( "str is not an object" );
if (i32 is Object) // CS0183
Console.WriteLine( "i32 is an object" );
else
Console.WriteLine( "i32 is not an object" ); // never reached
}
public static void Main()
{
F(0, "CS0183");
F(120, null);
}
}
Collaborate with us on GitHub
The source for this content can be found on GitHub, where you can also create and review issues and pull requests. For more information, see our contributor guide.