<summary>
Get site User IP
</summary>
<returns></returns>
public static string Getuserip ()
{
return httpcontext.current.request.servervariables["REMOTE_ADDR"]. ToString ();
}
<summary>
Remove the last ', ' number of a string
</summary>
<param name= "CHR": String to be processed </param>
<returns> returns the processed string </returns>
public static string Lost (String chr)
{
if (CHR = null | | chr = = string. Empty)
{
Return "";
}
Else
{
CHR = Chr. Remove (Chr. LastIndexOf (","));
return CHR;
}
}
<summary>
Remove the first '/' number of the string
</summary>
<param name= "CHR" > String to be processed </param>
<returns> returns the processed string </returns>
public static string Lostfirst (String chr)
{
String FLG = "";
if (Chr!= string. Empty | | CHR!= null)
{
if (Chr. Substring (0, 1) = = "/")
FLG = Chr. Replace (Chr. Substring (0, 1), "");
Else
FLG = CHR;
}
return FLG;
}
<summary>
Replace special characters in HTML
</summary>
<param name= "TheString" > Text that needs to be replaced. </param>
<returns> Replace the finished text. </returns>
public static string HtmlEncode (String thestring)
{
TheString = Thestring.replace (">", ">");
TheString = Thestring.replace ("<", "<");
TheString = Thestring.replace ("", "");
TheString = Thestring.replace ("", "");
TheString = Thestring.replace ("\" "," "");
TheString = Thestring.replace ("\", "'");
TheString = Thestring.replace ("\ n", "<br/>");
return thestring;
}
<summary>
Restore special characters in HTML
</summary>
<param name= "TheString" > Text that needs to be restored. </param>
<returns> restore good text. </returns>
public static string Htmldiscode (String thestring)
{
TheString = Thestring.replace (">", ">");
TheString = Thestring.replace ("<", "<");
TheString = Thestring.replace ("", "");
TheString = Thestring.replace ("", "");
TheString = Thestring.replace ("" "," "\");
TheString = Thestring.replace ("'", "\");
TheString = Thestring.replace ("<br/>", "\ n");
return thestring;
}
<summary>
Generate random numbers
</summary>
<param name= "Length" > Build length </param>
<returns></returns>
public static string number (int Length)
{
Return number (Length, false);
}
<summary>
Generate random numbers
</summary>
<param name= "Length" > Build length </param>
<param name= "Sleep" > whether to block the current thread before it is built to avoid duplication </param>
<returns></returns>
public static string number (int. Length, BOOL Sleep)
{
if (sleep)
System.Threading.Thread.Sleep (3);
string result = "";
System.Random Random = new Random ();
for (int i = 0; i < Length; i++)
{
result = random. Next (10). ToString ();
}
return result;
}
current 1/2 page
1 2 Next read the full text