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/

相关文章:

  • 1970-01-01
  • 2021-09-08
  • 2021-12-04
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-09-27
  • 2021-12-10
  • 2022-02-10
  • 2022-01-06
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案