You can add bold tag <b> from c# to first part of string like below
string stringA = "abc";
string stringB = "123";
string stringC = "xyz";
string Final = "<b>" + stringA +"</b>" + stringB + stringC;
If you want to have a more generic approach you can create a method like below
/// <summary>
/// Formaatedstrings the specified mainvalue.
/// </summary>
/// <param name="mainvalue">The mainvalue.</param>
/// <param name="partvalue">The partvalue.</param>
/// <returns></returns>
public string formaatedstring(string mainvalue, string partvalue)
{
return Regex.Replace(mainvalue, partvalue, @"<b>$0</b>", RegexOptions.IgnoreCase);
}
and then call above method like below
var result = this.formaatedstring(Final, stringA);
1条答案
按热度按时间2ul0zpep1#