Results 1 to 5 of 5

Thread: Equivilent of VB's Chr$()

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Sep 2002
    Posts
    78

    Equivilent of VB's Chr$()

    Say you have this in VB:

    Dim i As Integer
    i = 65
    Msgbox(Chr$(i))

    this will pop up "A". How do I do this in C#?

    Thanks,
    AnT

  2. #2
    Frenzied Member DevGrp's Avatar
    Join Date
    Nov 2001
    Location
    Charlotte, NC
    Posts
    1,256
    Try this
    Code:
    Convert.ToChar();
    Dont gain the world and lose your soul

  3. #3
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    To get a string out of an ASCII code (that's what Chr$ does I think) you'd do
    Convert.ToString(number)
    or simply
    number.ToString()
    given it is already available as an IntXX object.
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  4. #4
    Frenzied Member DevGrp's Avatar
    Join Date
    Nov 2001
    Location
    Charlotte, NC
    Posts
    1,256
    number.ToString() simply return a string representation of the number. He wants to convert the number to its matching character.
    Dont gain the world and lose your soul

  5. #5
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    Oh, in that case that would be
    ((char)number).ToString()
    e.g.
    ((char)65).ToString()
    results in "A"
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

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