Switcheroo【难度:1级】:
答案1:
public class Kata
{
public static string Switcheroo(string x)
{
return x.Replace("a","d").Replace("b","a").Replace("d","b");
}
}
答案2:
public class Kata
{
public static string Switcheroo(string x)
{
return x.Replace('a','d')
.Replace('b','a')
.Replace('d','b');
}
}
答案3:
using System;
using System.Linq;
public class Kata
{
public static string Switcheroo(string x)
{
var s = x.Select(c=> c == 'a' ? 'b' : (c=='b' ? 'a' : c)).ToArray(<