Results 1 to 5 of 5

Thread: [RESOLVED] 1 is a number or a character.

Threaded View

  1. #1

    Thread Starter
    PowerPoster eranga262154's Avatar
    Join Date
    Jun 2006
    Posts
    2,201

    Resolved [RESOLVED] 1 is a number or a character.

    Just look the following code fragment.

    Code:
    Console.WriteLine("The number " + '1' + " as a character have int value " +(int)'1' + ".");
    
    Console.WriteLine("The number " + “1” + " as a number have int value " +        (int)(1) + ".");
    The output is,

    Code:
    The number 1 as a character has int value 49.
    The number 1 as a number has int value 1.
    I never use a number as character and got this by mistake one of my application.

    What I want to know what, if I use a number (integer value) as a character it holds another integer value. What is the meaning/purpose of that?

    Just forget about the casting on code line 2. I put it there to keep similarities between two code lines.
    Last edited by eranga262154; Jun 10th, 2007 at 10:24 PM. Reason: Incorrect
    “victory breeds hatred, the defeated live in pain; happily the peaceful live giving up victory and defeat” - Gautama Buddha

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width