あにす #5663(2008/02/03 06:43 GMT) [ C# ] Rating1/1=1.00
発展版です。 最近C#3.0にしたので嬉しくて拡張メソッドにしてみました。
1 2 3 4 5 6 7 8 9 10 11 12 13 14
//http://ja.doukaku.org/148/ 投稿用 using System; static class Program { static string Tr(this string target, string from, string to) { for(int i = 0; i <= from[2] - from[0]; i++) { target = target.Replace((char)(from[0] + i), (char)(to[0] + i)); } return target; } static void Main(string[] args) { Console.WriteLine("ABCDEF".Tr("A-D", "a-d")); Console.ReadLine(); } }
Rating1/1=1.00-0+
1 reply [ reply ]
あにす
#5663()
[
C#
]
Rating1/1=1.00
発展版です。 最近C#3.0にしたので嬉しくて拡張メソッドにしてみました。
Rating1/1=1.00-0+
1 reply [ reply ]