c#搜索和替换

本文关键字:替换 搜索 | 更新日期: 2023-09-27 18:14:09

我是c#的初学者。我想做一个小工具来搜索&代替

我有这样的输入:

"name"  => "Hello world",      

我想要这个输出:

'name'   =>__( 'Hello world','$Variable'),  

这是我的尝试:

 private string ReplaceBackgroundDirection(string Source)
        {
Source = Source.Replace("name", "name");
Source = Source.Replace("=>"+"", "=> __(");

c#搜索和替换

我猜你想返回被替换的字符串:

private string ReplaceBackgroundDirection(string Source)
 {
    return Source.Replace("'"", "'").Replace("=>","=>__(") + "'$Variable'),";
 }