Skip to content

ErcanOPAK.com

  • ASP.Net WebForms
  • ASP.Net MVC
  • C#
  • SQL
  • MySQL
  • PHP
  • Devexpress
  • Reportviewer
  • About
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:

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
Post Views: 3

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 *

August 2022
M T W T F S S
1234567
891011121314
15161718192021
22232425262728
293031  
« Jul    

Most Viewed Posts

  • Get the First and Last Word from a String or Sentence in SQL (362)
  • How to use Map Mode for Vertical Scroll Mode in Visual Studio (234)
  • Find numbers with more than two decimal places in SQL (203)
  • Confirm before process with ASPxButton in Devexpress (199)
  • Add Constraint to SQL Table to ensure email contains @ (199)
  • ASPxGridView – Disable CheckBox based on condition in GridViewCommandColumn (198)
  • How to solve “Response.Redirect cannot be called in a Page callback” for DevExpress Components (197)
  • How to make some specific word(s) Bold or Underline in ReportViewer (191)
  • Devexpress ASPxGridview Column Grouping in Code (183)
  • Tense Changes When Using Reported Speech (171)

Recent Posts

  • How to create the ShowBlanksValue and ShowNonBlanksValue items in Devex Grid
  • How to get ‘n’th row in Sql Query with OFFSET FETCH NEXT and ROW_NUMBER()
  • How to change the style of scrollbar with CSS
  • How to add scroll bar to div in Asp.Net
  • How to solve “Fatal: Not possible to fast-forward, aborting” problem
  • How to add Output Parameter to SqlDataSource
  • How to get stored procedure parameters details in SQL
  • How to add default value for Entity Framework migrations for DateTime and Bool
  • String Interpolation, String Format, String Concat and String Builder in C#
  • How to get triggers create and update date in SQL

Recent Posts

  • How to create the ShowBlanksValue and ShowNonBlanksValue items in Devex Grid
  • How to get ‘n’th row in Sql Query with OFFSET FETCH NEXT and ROW_NUMBER()
  • How to change the style of scrollbar with CSS
  • How to add scroll bar to div in Asp.Net
  • How to solve “Fatal: Not possible to fast-forward, aborting” problem

Most Viewed Posts

  • Get the First and Last Word from a String or Sentence in SQL (362)
  • How to use Map Mode for Vertical Scroll Mode in Visual Studio (234)
  • Find numbers with more than two decimal places in SQL (203)
  • Confirm before process with ASPxButton in Devexpress (199)
  • Add Constraint to SQL Table to ensure email contains @ (199)

Social

  • ErcanOPAK.com
  • GoodReads
  • LetterBoxD
  • Linkedin
  • The Blog
  • Twitter

© 2022 ErcanOPAK.com

Proudly powered by WordPress | Theme: Xblog Plus by wpthemespace.com