Compilor error, run no error

Posted on 2005-04-10
Last Modified: 2010-04-16
hi all, following is my code

class Example3_9{
      public static void Main(){
            int myInt = 0;
                bool compatible = myInt is int;
            System.Console.WriteLine("myInt is int: "+compatible);

it compiled with error, yet being able to run successfully. The error message i got was the following

Example3_9.cs(5,35): warning CS0183:
The given expression is always of the provides ('int') type
Question by:eturfclub
    LVL 21

    Accepted Solution

    it's not an error, it's just warning.
    And what it's saying, "The given expression is always of the provided ('int') type", means that you set myInt as int:

    int myInt = 0;

    and regardless of how many times you check its type:

    bool compatible = myInt is int;

    myInt will be alway int.

    Just to give a contrary example

    foreach( Control c in this.Controls )
       if( c is Button )
          (( Button )c ).BackColor = Color.Red;

    in this case c can be anything including Button


    Author Comment


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    What Security Threats Are You Missing?

    Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

    In order to hide the "ugly" records selectors (triangles) in the rowheaders, here are some suggestions. Microsoft doesn't have a direct method/property to do it. You can only hide the rowheader column. First solution, the easy way The first sol…
    Article by: Najam
    Having new technologies does not mean they will completely replace old components.  Recently I had to create WCF that will be called by VB6 component.  Here I will describe what steps one should follow while doing so, please feel free to post any qu…
    It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
    Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

    759 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    10 Experts available now in Live!

    Get 1:1 Help Now