首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > C# >

其实高亮文字很容易实现。解决思路

2012-02-25 
其实高亮文字很容易实现。。。C# codeusing Systemusing System.Textusing System.Text.RegularExpressions

其实高亮文字很容易实现。。。

C# code
using System;using System.Text;using System.Text.RegularExpressions;public class HighBright{    public enum ChooseColorForText    {        Red, Green, Blue, Yellow, Black, Orange, Sienna, LightPink,    }    public enum ChooseSizeForText    {        A1 = 50, A2 = 40, A3 = 30, A4 = 20, A5 = 10,    }    public static string ChangeKeyWordColor(string strHtml, string strKeyWord, ChooseColorForText color, ChooseSizeForText size)    {        return Regex.Replace(strHtml, strKeyWord, "<font color=\"" + color + "\"><b style=\"font-size:" + (int)size + "px;\">" + strKeyWord+ "</b></font>\n", RegexOptions.IgnoreCase);    }} Response.Write(HighBright.ChangeKeyWordColor("abc", "a", HighBright.ChooseColorForText.Blue, HighBright.ChooseSizeForText.A1));//显示结果如下:



HTML code
><font color="Blue"><b style="font-size: 50px;">a</b></font>bc


[解决办法]
收获不小,接分
[解决办法]
我还以为是WinForm里面的高亮文字呢。

热点排行