在C#中的Asc? [英] Asc in C#?
问题描述
你好。
VB6有这个叫做Asc的功能(''''')
那我怎么能编写那个功能在c#?我想返回
一个int。
问候,
Chua Wen Ching:p
只需将char转换为int
char a =''a'';
int asc = a; //第一种方式
int asc2 = Convert.ToInt32(a); //第二种方式
Yves
" Chua Wen Ching" < CH ********** @ chuawenching.com> schreef in bericht
news:06 **************************** @ phx.gbl ... < blockquote class =post_quotes>你好。
VB6有这个函数叫做Asc('''')
那么如何在c#中编写该函数?我想返回
一个int。
问候,Chua Wen Ching:p
Phoenix ,这也是我对这个问题的第一反应,但如果你在$ 130或-20左右进入扩展的asc值,那么
就会变得非常明显在它的工作方式。我会
建议拉入VisualBasic名称空间并使用VB.Net asc()。
它将适合你。
>
" phoenix" < PA ****** @ skynetWORK.be>在消息新闻中写道:< #D ************** @ TK2MSFTNGP10.phx.gbl> ...只需将char转换为int
char a =''a'';
int asc = a; //第一种方式
int asc2 = Convert.ToInt32(a); //第二种方式
Yves
Chua Wen Ching < CH ********** @ chuawenching.com> schreef in bericht
新闻:06 **************************** @ phx.gbl ...你好。
VB6有这个函数叫做Asc('''')
那么如何在c#中编写该函数?我想返回
一个int。
问候,
Chua Wen Ching:p
Quizical< Co ************ @ yahoo.com>写道:Phoenix,这也是我对这个问题的第一反应,但是如果你在130 +或 - 20左右进入扩展的asc值,那么
就变成了它的工作方式有很明显的不同。我建议拉入VisualBasic名称空间并使用VB.Net asc()。
然后它会正常工作。
不 - 这只是一个解决你*真正*意味着什么的案例。 Asc
表示ASCII。对我来说,*没有大约127的ASCII值。
然而,你*可能*实际想要的是一个字符的默认系统编码
,其中使用Encoding.Default的情况是最好的方式
去。
见 http://www.pobox.com/~skeet/csharp/unicode.html 了解更多详情。
-
Jon Skeet - < sk *** @ pobox.com>
http://www.pobox.com/~skeet/
如果回复该群组,请不要给我发邮件太
Hi there.
VB6 had this function called Asc(''a'')
So how can i code that function in c#? I want to return
an int.
Regards,
Chua Wen Ching :p
Just convert the char to an int
char a = ''a'';
int asc = a; // First way
int asc2 = Convert.ToInt32(a); // Second way
Yves
"Chua Wen Ching" <ch**********@chuawenching.com> schreef in bericht
news:06****************************@phx.gbl...Hi there.
VB6 had this function called Asc(''a'')
So how can i code that function in c#? I want to return
an int.
Regards,
Chua Wen Ching :p
Phoenix, this was my first response for this problem also, but if you
get into the extended asc values somewhere around 130 + or - 20, there
becomes a very distinct difference in the way that it works. I would
advise pulling in the VisualBasic name space and use the VB.Net asc().
It will work properly for you then.
"phoenix" <pa******@skynetWORK.be> wrote in message news:<#D**************@TK2MSFTNGP10.phx.gbl>...Just convert the char to an int
char a = ''a'';
int asc = a; // First way
int asc2 = Convert.ToInt32(a); // Second way
Yves
"Chua Wen Ching" <ch**********@chuawenching.com> schreef in bericht
news:06****************************@phx.gbl...Hi there.
VB6 had this function called Asc(''a'')
So how can i code that function in c#? I want to return
an int.
Regards,
Chua Wen Ching :p
Quizical <Co************@yahoo.com> wrote:Phoenix, this was my first response for this problem also, but if you
get into the extended asc values somewhere around 130 + or - 20, there
becomes a very distinct difference in the way that it works. I would
advise pulling in the VisualBasic name space and use the VB.Net asc().
It will work properly for you then.
No - it''s just a case of working out what you *really* mean. "Asc"
suggests "ASCII" to me, and there *are* no ASCII values about 127.
However, what you *may* actually want is the default system encoding
for a character, in which case using Encoding.Default is the best way
to go.
See http://www.pobox.com/~skeet/csharp/unicode.html for more details.
--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet/
If replying to the group, please do not mail me too
这篇关于在C#中的Asc?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!