Skip to content

Bits of .NET

Daily micro-tips for C#, SQL, performance, and scalable backend engineering.

  • Asp.Net Core
  • C#
  • SQL
  • JavaScript
  • CSS
  • About
  • ErcanOPAK.com
C#

String Interpolation, String Format, String Concat and String Builder in C#

- 12.06.22 - ErcanOPAK

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:

.NET Core Dependency Injection “Multiple Registrations” Bug

C# “Background Task Randomly Stops” — Lost Exceptions in Fire-and-Forget

Define a Default Value when insert New Record From ASPxGridView

Post Views: 55

Post navigation

How to get triggers create and update date in SQL
How to add default value for Entity Framework migrations for DateTime and Bool

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

December 2025
M T W T F S S
1234567
891011121314
15161718192021
22232425262728
293031  
« Nov    

Most Viewed Posts

  • Get the User Name and Domain Name from an Email Address in SQL (915)
  • Get the First and Last Word from a String or Sentence in SQL (798)
  • How to select distinct rows in a datatable in C# (772)
  • How to add default value for Entity Framework migrations for DateTime and Bool (772)
  • How to make theater mode the default for Youtube (592)
  • Add Constraint to SQL Table to ensure email contains @ (558)
  • How to enable, disable and check if Service Broker is enabled on a database in SQL Server (533)
  • Average of all values in a column that are not zero in SQL (505)
  • Find numbers with more than two decimal places in SQL (421)
  • How to use Map Mode for Vertical Scroll Mode in Visual Studio (416)

Recent Posts

  • VS “Auto-Using Not Working” — The Broken Roslyn Cache Fix
  • WP “Plugin Update Breaks Site” — The Rollback Life-Saver
  • Windows 11 “SSD Suddenly Slow” — Disabled Write Caching
  • Windows 11 “CPU Stays High for No Reason” — SearchIndexer Loop Bug
  • AJAX “CORS Works in Postman But Fails in Browser” — Preflight Hell
  • JS “Object Mutation Side Effects” — The Hidden Reference Bug
  • HTML5 “Form Enter Key Submits Wrong Button” — The Invisible Default Button Rule
  • CSS “Text Overflow Ellipsis Not Working” — The Missing Combo
  • .NET Core “Configuration Not Updating” — Missing ReloadOnChange
  • ASP.NET Core “Middleware Never Executes” — The Ordering Trap

Most Viewed Posts

  • Get the User Name and Domain Name from an Email Address in SQL (915)
  • Get the First and Last Word from a String or Sentence in SQL (798)
  • How to select distinct rows in a datatable in C# (772)
  • How to add default value for Entity Framework migrations for DateTime and Bool (772)
  • How to make theater mode the default for Youtube (592)

Recent Posts

  • VS “Auto-Using Not Working” — The Broken Roslyn Cache Fix
  • WP “Plugin Update Breaks Site” — The Rollback Life-Saver
  • Windows 11 “SSD Suddenly Slow” — Disabled Write Caching
  • Windows 11 “CPU Stays High for No Reason” — SearchIndexer Loop Bug
  • AJAX “CORS Works in Postman But Fails in Browser” — Preflight Hell

Social

  • ErcanOPAK.com
  • GoodReads
  • LetterBoxD
  • Linkedin
  • The Blog
  • Twitter
© 2025 Bits of .NET | Built with Xblog Plus free WordPress theme by wpthemespace.com