Export (0) Print
Expand All
Expand Minimize

Compiler Warning (level 1) CS0183

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.

The following sample generates CS0183:

// CS0183.cs
// compile with: /W:1
using System;
public class Test
{
   public static void Main()
   {
      Object obj3 = null;
      String str2 = "CS0183";
      obj3 = str2;

      if ( obj3 is String )
         Console.WriteLine( "obj3 is String" );

      if ( str2 is Object )   // CS0183
         Console.WriteLine( "str2 is Object" );   
   }
}
Show:
© 2014 Microsoft