TrimUtil类:
using System.Collections;
using System;
namespace trimcharacter.Utils
{
public class TrimUtil
{
public static string trimCharacter(string src)
{
string dest = "";
for (int i = 0; i < src.Length; I++)
{
if(i < src.Length - 2 && src[i] == src[i + 2])
{
dest += src[i + 1];
i+=2;
}
else
{
dest += src[I];
}
}
return dest;
}
}
}
主程序类:
using System;
using trimcharacter.Utils;
namespace trimcharacter
{
class Program
{
static void Main(string[] args)
{
string src = "abacbcdadaaeecc";
Console.WriteLine(TrimUtil.trimCharacter(src));
}
}
}
程序输出: