欢迎光临
我们一直在努力

asp.net实现c#代码加亮显示_asp.net技巧

建站超值云服务器,限时71元/月

以下是代码片段:
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>”);
}

赞(0)
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com 特别注意:本站所有转载文章言论不代表本站观点! 本站所提供的图片等素材,版权归原作者所有,如需使用,请与原作者联系。未经允许不得转载:IDC资讯中心 » asp.net实现c#代码加亮显示_asp.net技巧
分享到: 更多 (0)