Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 831321
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T04:11:05+00:00 2026-05-15T04:11:05+00:00

Consider this code sample: public class Human { public string Value { get; set;}

  • 0

Consider this code sample:

public class Human {    
    public string Value { get; set;}
}
public class Car { 

    public static explicit operator Human (Car c) { 

        Human h = new Human();

        h.Value = "Value from Car";
        return h;
    }
}

public class Program { 
public static void Mani() { 
        Car c = new Car();

        Human h = (Human)c;
        Console.WriteLine("h.Value = {0}", h.Value);
        Console.WriteLine(c is Human);
}
}

Up I provide a possibility of an explicit cast from Car to Human, though Car and Human hierarchically are not related! The above code simply means that “Car is convertible to human”

However, if you run the snippet you will find the expression c is Human evaluates to false! I used to believe that the is operator is kinda expensive cause it attempts to do an actual cast that might result in an InvalidCastException. If the operator is trying to cast, then the cast should succeed as there’s an operator logic that should perform the cast!
What does “is” test?
Does test a hierarchical “is-a” relationship?

Does test whether a variable type “is convertible to” a type?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T04:11:06+00:00Added an answer on May 15, 2026 at 4:11 am

    The is operator tests for an actual type relation, not for ‘can cast’. Rightfully so.

    As for the ‘how does it do it’ part: I don’t know but I assume there are more efficient ways (reflection) to test for family ties than letting it come to an exception.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 509k
  • Answers 509k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer It looks like you are creating a new instance of… May 16, 2026 at 4:41 pm
  • Editorial Team
    Editorial Team added an answer As already stated, Array is faster. Actually it is orders… May 16, 2026 at 4:41 pm
  • Editorial Team
    Editorial Team added an answer This can easily happen if there is a proxy between.… May 16, 2026 at 4:41 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

Consider the following code: class Program { static void Main(string[] args) { Department deathStar
Considering the following sample code: // delivery strategies public abstract class DeliveryStrategy { ...
I have the following code class sample { public void update(List l) { l
Please, consider the following (I'm sorry for the amount of code; but this is
Consider i have a window Application,developed in Visual Studio 2005, having a button. I
I have a container class that has a generic parameter which is constrained to
Let's first consider a simple scenario ( see complete source on ideone.com ): import
I was going through someone's code where I came across a thread: while(TRUE) {
I am no IL master of any sort, I just use it sometimes to
What's the best way to call a generic method when the type parameter isn't

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.