String
<summary>
function: Accurately intercept a specified length of string as required
2 English in Chinese is a
Parameters: Str to intercept character, Len intercept length symbol denotes character (...)
</summary>
public static string Gottopic (string str,int len,string symbol)
{
int count = 0;
String strtemp = "";
str = nohtml (str);
for (int i = 0; i < str. Length; i++)
{
if (Math.Abs ((int) (str. Substring (i, 1). ToCharArray ()) [0])) > 255)
{
Count + 2;
}else
{
Count + 1;
}
if (Count <= len)
{
strtemp = str. Substring (i, 1);
}
Else
{
return strtemp + symbol;
}
}
return str;
}
<summary>
Filter out HTML tags
</summary>
<param name= "str" ></param>
<returns></returns>
public static string nohtml (String str)
{
str = regex.replace (str, @ "\<.[ ^\<]*\>) "," ", Regexoptions.ignorepatternwhitespace | Regexoptions.ignorecase);
str = regex.replace (str, @ "(\<\/[^\<]*\>)", "", Regexoptions.ignorecase | Regexoptions.ignorepatternwhitespace);
return str;
}