We will try to return a string like: “I can text whatever I want with 4 different options in C#. ” with String Interpolation, String Format, String Concat, and String Builder.
public class StringOptions { private string data1 = "4"; private string data2 = "C#"; public string StringInterpolation() => ($"I can text whatever I want with {data1} different options in {data2}."); public string StringFormat() => string.Format("I can text whatever I want with {0} different options in {1}.", data1, data2); public string StringConcat() => "I can text whatever I want with " + data1 + " different options in " + data2 + "."; public string StringBuilder() => (new StringBuilder()).Append("I can text whatever I want with ").Append(data1).Append(" different options in ").Append(data2).Append(".").ToString(); }
Related posts:
Constructors and Its Types in C#
How to create the ShowBlanksValue and ShowNonBlanksValue items in Devex Grid
ASPxGridView - Disable CheckBox based on condition in GridViewCommandColumn
Determine If string contains more than 1 value in C#
How to add placeholder to Multiple Selection DropDownList in Asp.Net MVC