[Webinar] Learn how to a build a cloud-first strategyRegister Now


Compilor error, run no error

Posted on 2005-04-10
Medium Priority
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

Yurich earned 1600 total points
ID: 13750155
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

ID: 13750188

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Summary: Persistence is the capability of an application to store the state of objects and recover it when necessary. This article compares the two common types of serialization in aspects of data access, readability, and runtime cost. A ready-to…
This article introduced a TextBox that supports transparent background.   Introduction TextBox is the most widely used control component in GUI design. Most GUI controls do not support transparent background and more or less do not have the…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …
When cloud platforms entered the scene, users and companies jumped on board to take advantage of the many benefits, like the ability to work and connect with company information from various locations. What many didn't foresee was the increased risk…
Suggested Courses
Course of the Month20 days, 9 hours left to enroll

868 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