判断和添加 theResult + "," + longId - AddOrUpdateId
2017-02-05 10:41:46 访问(1333) 赞(0) 踩(0)
/// <summary>
/// 判断和添加 theResult + "," + longId
/// </summary>
/// <param name="theResult"></param>
/// <param name="longId"></param>
/// <returns></returns>
public static string AddOrUpdateId(string theResult, long longId)
{
string strLongId = longId.ToString();
if (theResult == null || theResult.Length == 0)
{
return strLongId;
}
if (theResult == strLongId)
{
return theResult;
}
else
{
StringBuilder sbLeft = new StringBuilder(",");
sbLeft.Append(theResult);
sbLeft.Append(",");
StringBuilder sbRight = new StringBuilder(",");
sbRight.Append(strLongId);
sbRight.Append(",");
if(sbLeft.ToString().Contains(sbRight.ToString()))
return theResult;
return theResult + "," + strLongId;
}
}
/// <summary>
/// 判断和添加 theResult + "," + longId
/// </summary>
/// <param name="theResult"></param>
/// <param name="longId"></param>
/// <param name="strLinkChar"></param>
/// <returns></returns>
public static string AddOrUpdateId(string theResult, long longId, string strLinkChar)
{
string strLongId = longId.ToString();
if (theResult == null || theResult.Length == 0)
{
return strLongId;
}
if (theResult == strLongId)
{
return theResult;
}
else
{
StringBuilder sbLeft = new StringBuilder(strLinkChar);
sbLeft.Append(theResult);
sbLeft.Append(strLinkChar);
StringBuilder sbRight = new StringBuilder(strLinkChar);
sbRight.Append(strLongId);
sbRight.Append(strLinkChar);
if (sbLeft.ToString().Contains(sbRight.ToString()))
return theResult;
return theResult + strLinkChar + strLongId;
}
}
标签:
判断和添加 theResult + " 


" + longId - AddOrUpdateId 


上一条:
下一条:
相关评论
发表评论