The core code is from aspnetforums.
Stringwriter textbuffer = new stringwriter ();
Match match = RegEx. Match (htmlstr, @ "\", regexoptions. ignorecase | regexoptions. Compiled );
If (match = NULL)
{
Response. Write (htmlstr );
Return;
}
String codetype = match. Groups ["codetype"]. value;
String content = match. Groups ["codecontent"]. value;
If (codetype = string. Empty | content = string. Empty)
{
Response. Write (htmlstr );
Return;
}
// MessageBox. Show (codetype );
// MessageBox. Show (content );
String [] Sr = content. Split (convert. tochar ("\ n "));
If (codetype = "C #")
{
Textbuffer. Write ("<CSHARP> \ r \ n ");
Foreach (string sourceline in SR)
{
Textbuffer. Write (fixcsline (sourceline ));
Textbuffer. Write ("\ r \ n ");
}
Textbuffer. Write ("</CSHARP> ");
}
Else if (codetype = "jscript. Net ")
{
Textbuffer. Write ("<JScript. Net> \ r \ n ");
Foreach (string sourceline in SR)
{
Textbuffer. Write (fixjsline (sourceline ));
Textbuffer. Write ("\ r \ n ");
}
Textbuffer. Write ("</JScript. Net> ");
}
Else if (codetype = "VB ")
{
Textbuffer. Write ("<VB> \ r \ n ");
Foreach (string sourceline in SR)
{
Textbuffer. Write (fixvbline (sourceline ));
Textbuffer. Write ("\ r \ n ");
}
Textbuffer. Write ("</vB> ");
}
The effect is as follows:
Http://forums.coder.cn/forum/topic.aspx? Author_id = 2 & topic_id = 11 & category_id = 9