How to replace VB's Chr() function in C#

csharp Albania
  • 12 years ago

    Hi everyoneBig Smile [:D],

    I'm trying to write a function that should do the same thing that does Chr() function in .NET. A solution to the problem could be this piece of code :


    static string Chr(int p_intByte)


    if( (p_intByte < 0) || (p_intByte > 255) )


    throw new ArgumentOutOfRangeException("p_intByte", p_intByte, "Duhet te jete midis 1 dhe 255.");


    byte[] bytBuffer = new byte[]{(byte) p_intByte};

    return Encoding.GetEncoding(1252).GetString(bytBuffer);


    But I have a problem. I'm using Visual Studio 2003 and it doesn't have the System.Text.Encoding class.

    So, can I get a solution to this problem???????????????


  • 12 years ago
    The Encoding class is NOT new.  It exists in version 1.1 of the Framework.  In fact, it exists in version 1.0 of the Framework.

Post a reply

Enter your message below

Sign in or Join us (it's free).


Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“Nine people can't make a baby in a month.” - Fred Brooks