using System;
using System.Collections.Generic;
using System.Text;
namespace ConsoleApplication1
{
class Program
{
//截取字符串
public string Remove_String(string strAreaID, string rootAreaID)
{
string strNewString = "";
if (strAreaID == "")
{
strNewString = "";
}
else
{
bool bStrID = Split_String(strAreaID, rootAreaID);
if (bStrID == false)
{
strNewString = strAreaID.Remove(strAreaID.Length - 1);
}
else
{
strNewString = rootAreaID;
}
}
return strNewString;
}
public bool Split_String(string strAreaID, string rootAreaID)
{
bool bStrAreaID = false;
StringBuilder sb1 = new StringBuilder();
string strNewString = "";
if (strAreaID == "")
{
strNewString = "";
}
else
{
string[] strArr = strAreaID.Split(',');
if (strArr.Length > 0)
{
for (int i = 0; i < strArr.Length - 1; i++)
{
if (strArr[i] == rootAreaID)
{
bStrAreaID = true;
}
}
}
else
{
//为空了
}
strNewString = sb1.ToString();
}
return bStrAreaID;
}
static void Main(string[] args)
{
string StrAreaID = "sa,dd,d,a,as,e,rer,r,4,df";
string RootAreaID = "a";
Program program = new Program();
//program.Split_String(StrAreaID, RootAreaID);
string temp=program.Remove_String(StrAreaID, RootAreaID);
Console.WriteLine(temp);
Console.Read();
}
}
}
http://shanggq2009.blog.163.com/blog/static/12342058220097315750409/
浙公网安备 33010602011771号