在C#中转换strtr php函数 [英] Conversion of strtr php function in C#
本文介绍了在C#中转换strtr php函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
需要在C#中转换此php代码
Need to convert this php code in C#
strtr($input, '+/', '-_')
是否存在等效的C#函数?
Does an equivalent C# function exist?
推荐答案
PHP
方法strtr()
是转换方法,而不是string replace
方法.
如果要在C#
中执行相同操作,请使用以下命令:
The PHP
method strtr()
is translate method and not string replace
method.
If you want to do the same in C#
then use following:
根据您的评论
string input = "baab";
var output = input.Replace("a", "0").Replace("b","1");
注意:在
C#
中没有与strtr()
完全相似的方法.
Note : There is no exactly similar method like
strtr()
inC#
.
您可以找到有关String.Replace方法的更多信息这里
这篇关于在C#中转换strtr php函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文