C#中的ASCII代码 [英] ASCII code in c#

查看:286
本文介绍了C#中的ASCII代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



如何在运行时更改ASCII代码字符?

请帮助我.

Hi,

How to change ASCII code char at run time?

Please help me.

推荐答案

尽管您的问题仍然不清楚,但如果我正确理解了您的问题,我想回答一下,希望您也同样如此.

请参阅此处 ASCII [ ^ ]表.

编写一个程序,将相应的ASCII字符转换为所需的格式,为此, THIS [ ^ ]简单的编程将帮助您实现目标.

[更新]
啊!!!感谢您进行更新,如此简单.

请参见 [ ^ ]那里的小线程可以为您提供帮助.
Though your question is not clear anyway I would like to answer if I''ve understood your question correctly, Hope you are asking the same.

See Here full ASCII[^] Table.

Write a program that can convert corrosponding ASCII char to required format it accordingly, For that THIS[^] simple programming will help you towards.

[update]
Ah!!! Thanks for updating it''s such a simple thing.

See THIS[^] tiny thread there to help you.


可能您的问题有所不同.您真的应该更好地解释.

问题是类型System.String是不可变的.您不能修改字符串中的字符.

如果可能是这样的话:

Probably your problem is different. You really should explain better.

The problem is the type System.String is immutable. You cannot modify a character in a string.

If could be something like this:

static string ReplaceCharacter(string source, int position, byte ASCII) {
    string modified = char.ConvertFromUtf32(ASCII);
    return string.Format( //press F1 on word "Format"
        "{0}{1}{2}",
        source.Substring(0, position - 1),
        modified,
        source.Substring(position + 1));
} //ReplaceCharacter



这样,您无需修改​​字符串对象,而是用新构造的字符串替换字符串.这就是代码始终处理字符串的方式.

也许,您的替代品并不是您真正需要的.如果您要尝试使用自制的方法来设置带有参数的字符串格式,请查看标准.NET字符串格式-获取源代码示例(如上),输入F1的注释方式,并查看Microsoft帮助-很好记录的主题.

我也不明白波斯语如何可以是ASCII.通常,这是Unicode.如果您的意思是所有字符串都可以是波斯语,但是只有要替换的字符是ASCII,则我的方法将起作用.

同样,如果解决了错误的问题,也不要怪我.您的解释尚不清楚,以至于Hiren想到了一件事,而我却想到了另一件事.



This way you don''t modify a string object, you replace a string with newly constructed string. This is how code always deals with strings.

Maybe, your replacement is not what you really need. If you''re trying to device home-baked way of formatting strings with parameters, look at standard .NET string formatting -- take the source code sample (above), type F1 how it is commented and see Microsoft help -- very well documented topic.

I also don''t understand how Persian can be ASCII. Normally, this is Unicode. If you mean that all the strings can be Persian, but only the character to replace is ASCII my method will work.

Again, don''t blame me if it solved wrong problem. Your explanation is so unclear that Hiren thought of one thing, and I am of another.


这篇关于C#中的ASCII代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆