find a location for property in a new city

Thursday, 23 September 2010

Bet you didn't know about: C# Numerical suffixes

I love learning new things and you probably do too. So how about this one... I found a way to make a long, double, unsigned int etc without having to use casting or having to explicitly declare the type.

Instead of using explicit declarations and casting like this:

long l = 12;
var d = (double)12;
float f = 12.0; //compilation error
var u = (UInt32)12;
decimal m = 12;
ulong ul = 12;

You can use the numerical suffixes like this:

var l = 12L;
var d = 12D;
var f = 12.0F;
var u = 12U;
var m = 12M;
var ul = 12UL;

So there we are. Interesting? Or maybe everyone already knew that and I've only just found it.

Follow britishdev on Twitter

3 comments:


  1. Thanks for posting this useful content, Good to know about new things here, Let me share this, . Hadoop training in pune

    ReplyDelete
  2. Numeric suffixes, also known as the literal number suffixes, are hints of a certain kind for the compiler. Note, "literal" means a hard-coded value in your software. Assignment Writing UK

    ReplyDelete
  3. SAMBUCUS ELDERBERRY GUMMIES | 3-in-1 Immune SUPPORT:Give your immune system a boost with vegan Sambucus Elderberry gummies. These immune support gummies are deliciously sweet and packed with vitamins and antioxidants Vitamin C & Zinc.

    Source: Sambucus elderberry gummies

    ReplyDelete