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 1069567
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T20:26:18+00:00 2026-05-16T20:26:18+00:00

What I want to do is be told the type, value (if there is

  • 0

What I want to do is be told the type, value (if there is one at compile-time) and other information (I do not know what I need now) of a selection of an expression.

For example, if I have an expression like

int i = unchecked((short)0xFF);

selecting 0xFF will give me (Int32, 255), while selecting ((short)0xFF) will give me (Int16, 255), and selecting i will give me (Int32, 255).

Reason why I want such a feature is to be able to verify my assumptions. It’s pretty easy to assume that 0xFF is a byte but it is actually an int. I could of course refer to the C# Language Specifications all the time, but I think it’s inefficient to have to refer to it everytime I want to check something out. I could also use something like ANTLR but the learning curve is high.

I do intend to read the entire specs and learn ANTLR and about compilers, but that’s for later. Right now I wish to have tools to help me get the job done quickly and accurately.

Another case in point:

int? i = 0x10;
int? j = null;
int x;
x = (i >> 4) ?? -1;//x=1
x = (j >> 4) ?? -1;//x=-1

It may seem easy to you or even natural for the bottom two lines in the code above. (Maybe one should avoid code like these, but that’s another story) However, what msdn says about the null-coalescing operator is lacking information to tell me that the above code ((i>>4)??) is legal (yet it is, and it is). I had to dig into grammar in the specs to know what’s happening:

  • null-coalescing-expression
  • conditional-or-expression
  • conditional-and-expression
  • exclusive-or-expression
  • and-expression
  • equality-expression
  • relational-expression
  • shift-expression
  • shift-expression right-shift additive-expression
    … (and more)

Only after reading so much can I get a satisfactory confirmation that it is valid code and does what I think it does. There should be a much simpler way for the average programmer to verify (not about validity, but whether it behaves as thought or not, and also to satisfy my curiosity) such code without having to dive into that canonical manual. It doesn’t necessary have to be a VS plugin. Any alternative that is intuitive to use will do just as well.

  • 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-16T20:26:18+00:00Added an answer on May 16, 2026 at 8:26 pm

    Well, I’m not aware of any add-ins that do what you describe – however, there is a trick you can use figure out the type of an expression (but not the compile-time value):

    • Assign the expression to a var variable, and hover your mouse over the keyword var.

    So for example, when you write:

    var i = unchecked((short)0xFF); 
    

    and then hover your mouse over the keyword var, you get a tooltip that says something like:

    Struct System.Int16

    Represents a 16-bit signed integer.

    This is definitely a bit awkward – since you have to potentially change code to make it work. But in a pinch, it let’s you get the compiler to figure out the type of an expression for you.

    Keep in mind, this approach doesn’t really help you once you start throwing casts into the picture. For instance:

    object a = 0xFF;
    var z = (string)a;  // compiles but fails at runtime!
    

    In the example above, the IDE will dutifully report that the type of var z is System.String – but this is, of course, entirely wrong.

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

Sidebar

Related Questions

Every time that I want to do a Layout, I'm getting a black layout
I want the messagebox to only show if the number is equal to 0.
I want to use a temp directory that will be unique to this build.
I want to get the header of a selected tab-item of a tab-control and
I want to have generalised email templates. Currently I have multiple email templates with
If all tables I want to delete from have the column gamer_id can i
I'm working on a project in C# w/ XNA, and I want to reorganize
I'm in the process of porting some code from Linux to Mac OS X.
I'm trying to build a Chrome browser extension, that should enhance the way the
I am using a 3rd-party rotator object, which is providing a smooth, random rotation

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.