472,110 Members | 2,074 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,110 software developers and data experts.

Creating a char or String from ascii code

Hi
Can anyone tell me how to create an instance of a char or string from
an ascii character code.

That is if I wont to create a tab char (code 0009), how would I achieve
this.

I know about the slash characters \t and \n etc. but I need to be able
to do this manually.
Thanks

Nov 25 '05 #1
3 30162
Hi Phil,
I am not very sure what you meant with "manually", but it seems you
wanted some thing like this:
either
char c = '\u0009';
or
char c = '\x0009'
will work.
More on the C# lang spec.

Thi - http://thith.blogspot.com

Nov 25 '05 #2
Many thnaks worked a treat....

Nov 25 '05 #3
Phil Mc wrote:
Can anyone tell me how to create an instance of a char or string from
an ascii character code.


The easiest way is just to cast it:

int i = 9;
char c = (char)i;

Call ToString on the char to get a string.

Jon

Nov 25 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by glenn | last post: by
39 posts views Thread by Abubakar | last post: by
7 posts views Thread by Joris De Groote | last post: by
19 posts views Thread by many_years_after | last post: by
8 posts views Thread by ianenis.tiryaki | last post: by
2 posts views Thread by Maj | last post: by
reply views Thread by leo001 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.