Re: Character representation

From: Gas (gasxxx_at_hotmail.com)
Date: 10/12/04


Date: Tue, 12 Oct 2004 09:39:42 -0400

Just wondering do I really need the casting in C# here?
because I know in C++,
Char c= 65; will work

Gas

"James Curran" <JamesCurran@mvps.org> wrote in message
news:u9B3$yVrEHA.3712@TK2MSFTNGP15.phx.gbl...
> "Gas" <gasxxx@hotmail.com> wrote in message
> news:ukv7nvUrEHA.2732@TK2MSFTNGP09.phx.gbl...
>
>> Also is there any character to ASCII code and ASCII code to character
>> built-in function in C#?
>
>
> One of the things that programmers coming from Basic language variant
> to
> a C language variant have trouble with is that Basic imposes a completely
> unnecessary distinction between numbers & characters, which C (and C++ and
> C#) does not. So, the following code will print " A, 66":
>
> public class MyClass
> {
> public static void Main()
> {
> Char c =(Char) 65;
> int i = 'B';
> Console.WriteLine("{0}, {1}", c, i);
> }
> }
>
> Note that the cast it required to convert 65 to a character, but not to
> convert 'B' into an int.
>
>> I am wondering how can I representation some of the special characters in
>> C#?
>> (for example, we use vbKeyTab for Tab and vbCrLf for line feed in VB)
>
> So, with the above in mind, you can create Tab as a character simply
> by:
>
> char csKeyTab = (char) 9;
>
> However, you'll probably want them as string (and for vbCrLf, it would
> have to be), inwhich case you can use the predefined "escape codes":
>
> string csCrLf = "\r\n";
> string csKeyTab = "\t";
>
> But say you want a string containing a special character which doesn't
> have a predefined code? This can be done also, but you'll have to
> translate
> the ASCII code into Hexadecimal.
>
> string csABC = "\x41\x42\x43"; // "ABC" "A" = ASCII 65 (dec) = 41
> (hex)
>
> --
> Truth,
> James Curran
> Home: www.noveltheory.com Work: www.njtheater.com
> Blog: www.honestillusion.com Day Job: www.partsearch.com
> (note new day job!)
>
>



Relevant Pages

  • Need help to remove tbas, carriage retrun, and other!!!
    ... ASCII code of the character ... that I link to) to specify the string that you want to ... optionally the ascii chr number of the delimiter ... 'At the start point of the string (1 character after the ...
    (microsoft.public.access.queries)
  • Re: Will this SQL work to find records with hard returns in one of the text fields?
    ... >>There's a VBA constant, vbCrLf, that you can use for this, and use ... as it doesn't walk through the string character ...
    (comp.databases.ms-access)
  • Re: Linefeed to CrLf
    ... onlu puts a Lf character at the end of each row. ... Dim s As String ... vbcrlf replace and doing something like: ...
    (comp.databases.ms-access)
  • Re: Linefeed to CrLf
    ... onlu puts a Lf character at the end of each row. ... Function ReadAll(path As String) As String ... Dim s As String ... vbcrlf replace and doing something like: ...
    (comp.databases.ms-access)
  • How to do a line feed in a Text Box
    ... I've tried vbcrlf but that just places the "p" looking carriage return ... character in my string. ...
    (microsoft.public.excel.programming)