同时多次使用替换功能c#win。形成 [英] Use Replace function multiple times simultaneously c# win. form

查看:118
本文介绍了同时多次使用替换功能c#win。形成的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我被困在一个部分,我必须多次同时使用替换功能 c#win。表格。



示例

原始数据

I am stuck at a part where i have to use Replace function multiple times simultaneously c# win. form.

Example
Raw Data

myarray[0] = "A";
myarray[1] = "B";
myarray[2] = "C";





现在,我要替换所有 A B ,所有 B A ,结果应如下所示





Now, i want to replace all A with B and all B with A and result should be like below

myarray[0] = "B";
myarray[1] = "A";
myarray[2] = "C";







[注意:以上只是一个例子而且在实际中,我的数组中充满了所有可能的字符,所以请不要建议用其他东西替换它。]



我不能给你代码,因为我不知道怎么做。任何人都可以通过提供代码片段来帮助我吗?











谢谢advance




[Note:the above is just an example and in real, my array is filled with all possible characters so please don't suggest replacing it with something else.]

I cannot give you the code as i have no idea how to do this. Can anybody help me by providing a code snippet?





Thanks in advance

推荐答案

当你在谈论阵列时,你没有实际的问题!

所有你需要的是在所有的数组元素并根据你的规则替换它们。

所有元素将在循环中处理一次,这样你就可以得到你想要的确切结果!
As you are talking about an array you have no actual problem!
All you need is run a simple loop over all the array elements and replace them according to your rules.
All element will be handled once in the loop so you will get the exact result you are looking for!


这篇关于同时多次使用替换功能c#win。形成的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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