{"id":53049,"date":"2020-06-30T08:00:52","date_gmt":"2020-06-30T06:00:52","guid":{"rendered":"https:\/\/code-maze.com\/?p=53049"},"modified":"2022-11-04T14:49:19","modified_gmt":"2022-11-04T13:49:19","slug":"different-ways-concatenate-strings-csharp","status":"publish","type":"post","link":"https:\/\/code-maze.com\/different-ways-concatenate-strings-csharp\/","title":{"rendered":"A Few Different Ways to Concatenate Strings in C#"},"content":{"rendered":"<p>In this quick tutorial, we are going to talk about different ways to concatenate strings. Splitting and joining strings are commonly used operations in almost any real-world application, so let&#8217;s see how we can <strong>concatenate strings through some examples<\/strong>.<\/p>\n<p>We won&#8217;t cover methods that are not specifically meant for concatenating strings, like <code>Enumerable.Aggregate()<\/code> or any other generic methods that reuse the mechanisms from this article.<\/p>\n<p>Also, this is not an article about the performance of these methods, so be careful when using them.<\/p>\n<div style=\"padding: 20px; border-left: 5px #dc2323 solid; display: block; margin-bottom: 20px; box-shadow: 1px 1px 5px 0px lightgrey;\">The source code is available on the <a href=\"https:\/\/github.com\/CodeMazeBlog\/string-concatenation-csharp\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">GitHub repo<\/a>.<\/div>\n<p>Let&#8217;s dive in.<\/p>\n<h2><a id=\"introduction\"><\/a>What is String Concatenation?<\/h2>\n<p>Strings in C# are immutable which means that a string cannot be changed once it has been created. Any method or operator that appears to be changing the string is actually <strong>creating an entirely new string object<\/strong>. This is important to understand before we proceed further.<\/p>\n<p>As for the term &#8220;concatenate&#8221;, it&#8217;s a fancy way of saying &#8220;join&#8221; and it&#8217;s used to describe the<strong> merging of two or more string literals or objects<\/strong>. It&#8217;s a very common operation in C# as well as any other programming language.<\/p>\n<p>Besides concatenation, the String class provides us with many other useful methods. You can learn more about it in our <a href=\"https:\/\/code-maze.com\/csharp-basics-string-methods\/\" target=\"_blank\" rel=\"noopener noreferrer\">C# &#8211; Back To Basics article about strings<\/a>.<\/p>\n<h2><a id=\"operators\"><\/a>Using the + and the += Operators<\/h2>\n<p>These operators are familiar to anyone doing software programming, even those just beginning. They are easy to use and intuitive since we all did math in school. The <code>+<\/code> operator is not overloaded by the String class and if you&#8217;re concatenating string variables it&#8217;s translated to <code>String.Concat()<\/code> in the IL.<\/p>\n<p>Let&#8217;s take a look at the simplest example:<\/p>\n<pre class=\"EnlighterJSRAW\" title=\"plus operator\" data-enlighter-language=\"csharp\">string foo = \"Morning!\";\r\nstring bar = \"Nice day for fishing, ain't it?\";\r\n\r\nstring foobar = foo + \" \" + bar;\r\nConsole.WriteLine(foobar); \/\/ outputs \"Morning! Nice day for fishing, ain't it?\"<\/pre>\n<p>This is equal to <code>System.String.Concat(foo, \" \", bar)<\/code>.<\/p>\n<p>On the other hand, if you&#8217;re using just the string literals:<\/p>\n<pre class=\"EnlighterJSRAW\" title=\"Just the literals\" data-enlighter-language=\"csharp\">string foobar = \"Morning!\" + \" \" + \"Nice day for fishing, ain't it?\";\r\nConsole.WriteLine(foobar); \/\/ outputs \"Morning! Nice day for fishing, ain't it?\"<\/pre>\n<p>This won&#8217;t trigger the <code>Concat<\/code> method to be called and the value will be pushed to stack directly. Constants and literals concatenation happens at compile-time, and for the variables at runtime.<\/p>\n<p>The <code>+=<\/code> operator works similarly:<\/p>\n<pre class=\"EnlighterJSRAW\" title=\"+= example\" data-enlighter-language=\"csharp\">string foo = \"Morning!\";\r\nstring bar = \"Nice day for fishing, ain't it?\";\r\nstring[] foobar = { foo, \" \", bar };\r\n\r\nstring plusEqualsResult = String.Empty;\r\n\r\nfor (var index = 0; index &lt; foobar.Length; index++)\r\n{\r\n\tplusEqualsResult += foobar[index];\r\n}\r\n\r\nConsole.WriteLine(plusEqualsResult); \/\/ outputs \"Morning! Nice day for fishing, ain't it?\"<\/pre>\n<p>That&#8217;s it, pretty simple and intuitive.<\/p>\n<h2><a id=\"format\"><\/a>String.Format() Method<\/h2>\n<p>The <code>String.Format()<\/code> method is a method of the String class that helps us join and format our strings in various ways. It has eight overloads, and it&#8217;s very versatile.<\/p>\n<p>The most commonly used looks like this: <code>static String Format(String format, params object?[] args);<\/code><\/p>\n<p>Basically, that means it can insert any number of different objects into the string we provide, by using a special way to do so. Namely, you can insert one or more symbols {n} into the provided, where n starts at index 0. Once you&#8217;ve done that, you provide as many arguments as you have inserted placeholders.<\/p>\n<p>This might sound a bit confusing, so let&#8217;s see how it works in a simple example:<\/p>\n<pre class=\"EnlighterJSRAW\" title=\"String.Format example\" data-enlighter-language=\"csharp\">string foo = \"Morning!\";\r\nstring bar = \"Nice day for fishing, ain't it?\";\r\n\r\nstring foobar = String.Format(\"{0} {1}\", foo, bar);\r\nConsole.WriteLine(foobar); \/\/ outputs \"Morning! Nice day for fishing, ain't it?\"\r\n<\/pre>\n<p>As you can see, {0} and {1} represent foo and bar respectively. If there are more &#8220;inserts&#8221; than provided arguments, we&#8217;ll get a <code>FormatException<\/code> from the compiler.<\/p>\n<p>So this is invalid:<\/p>\n<pre class=\"EnlighterJSRAW\" title=\"Invalid format\" data-enlighter-language=\"csharp\">string foobar = String.Format(\"{0} {1} {2}\", foo, bar);<\/pre>\n<p>There are 3 places to insert strings, and only two arguments are provided, so this would cause the <code>FormatException<\/code> to be thrown.<\/p>\n<p>Nowadays, since C# 6 came out, we have a decent replacement for <code>String.Format()<\/code>, and it&#8217;s called string interpolation. We&#8217;ll see how string interpolation works a bit further on.<\/p>\n<h2><a id=\"concatenate\"><\/a>String.Concat() Method<\/h2>\n<p>The Concat method is the bread and butter of string concatenation. It&#8217;s used both explicitly and by the compiler to concatenate strings. It really powerful and versatile, and it has 13 different overloads.<\/p>\n<p>You can concatenate two or more strings, strings from an array, or <code>IEnumerable<\/code> and much more. We&#8217;ve even mentioned that <code>+<\/code> and <code>+=<\/code> operators are translated to <code>String.Concat()<\/code> by the compiler.<\/p>\n<p>When in doubt you can use <code>String.Concat()<\/code> to join strings:<\/p>\n<pre class=\"EnlighterJSRAW\" title=\"String.Concat() example\" data-enlighter-language=\"csharp\">string foo = \"Morning!\";\r\nstring bar = \"Nice day for fishing, ain't it?\";\r\n\r\nstring foobar = String.Concat(foo, \" \", bar); \/\/ outputs \"Morning! Nice day for fishing, ain't it?\"<\/pre>\n<p>Pretty straightforward and easy to use.<\/p>\n<h2><a id=\"interpolation\"><\/a>Using String Interpolation (C# 6 Feature)<\/h2>\n<p>String interpolation is the newest way of joining multiple strings. It&#8217;s very intuitive and easy to use. Once you learn to use interpolation you might even ditch <code>String.Format()<\/code> for good. <code>String.Format()<\/code> still has some usages though, but for the most part, you can use interpolation instead.<\/p>\n<p>To start using string interpolation to format your strings, you need to prefix a string with a &#8216;$&#8217; character. After that, you can use braces <code>{<\/code> and <code>}<\/code> to insert variables in such a string. Since braces are a special character, you can use double braces <code>{{ <\/code>and <code>}}<\/code> to write a brace in the interpolated string.<\/p>\n<p>You can also create an interpolated verbatim string by using &#8216;$&#8217; and then &#8216;@&#8217; (or in reverse order) to prefix the string.<\/p>\n<p>Let&#8217;s see how interpolation works in practice:<\/p>\n<pre class=\"EnlighterJSRAW\" title=\"String interpolation example\" data-enlighter-language=\"csharp\">string foo = \"Morning!\";\r\nstring bar = \"Nice day for fishing, ain't it?\";\r\n\r\nstring foobar = $\"{foo} {bar}\"; \/\/ outputs \"Morning! Nice day for fishing, ain't it?\"<\/pre>\n<p>As you can see it&#8217;s by far the least cumbersome and simple way of concatenating strings while formatting them at the same time.<\/p>\n<p>String interpolation is actually much more powerful and it can <a href=\"https:\/\/docs.microsoft.com\/en-us\/dotnet\/standard\/base-types\/composite-formatting#format-string-component\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">format strings in various ways<\/a>.<\/p>\n<h2><a id=\"join\"><\/a>Joining Strings with String.Join() Method<\/h2>\n<p>Another way of joining strings is by using a <code>String.Join()<\/code> method.<\/p>\n<p>But what makes <code>String.Join()<\/code> different from other methods we used so far?<\/p>\n<p><code>String.Join()<\/code> specializes in concatenating elements of an array or collection of strings or objects, and we decide how by providing a separator to the method.<\/p>\n<p>So if we have an array or a list of strings, and we need to join them, by using some kind of separator (can be an empty space too), we would use the <code>String.Join()<\/code> method.<\/p>\n<p>Let&#8217;s see how that works in our example:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"csharp\">string foo = \"Morning!\";\r\nstring bar = \"Nice day for fishing, ain't it?\";\r\nstring foobar = { foo, bar };\r\n\r\nstring foobar = String.Join(\" \", foobar); \/\/ outputs \"Morning! Nice day for fishing, ain't it?\"<\/pre>\n<p>This example doesn&#8217;t do it justice, but say for example you have an array of integers and you want to join them into one string and separate them by a comma:<\/p>\n<pre class=\"EnlighterJSRAW\" title=\"String.Join with int array\" data-enlighter-language=\"csharp\">int[] array = { 1, 2, 3, 4, 5, 6, 7, 8, 9 };\r\nstring foobar = String.Join(\",\", array); \/\/ outputs \"1,2,3,4,5,6,7,8,9\"<\/pre>\n<p>Okay, let&#8217;s move on to the last method.<\/p>\n<h2><a id=\"append\"><\/a>StringBuilder.Append() Method<\/h2>\n<p><code>StringBuilder<\/code> is a class that exists solely for the purpose of <strong>overcoming the string immutability<\/strong> &#8220;problem&#8221;. When working with a lot of string objects, we can easily allocate much more memory than we actually need to since every operation on those strings requires a new memory piece to be allocated.<\/p>\n<p>So to avoid this problem, the <code>StringBuilder<\/code> class has been created, and it doesn&#8217;t create new strings when it modifies them.<\/p>\n<p>So why don&#8217;t we use <code>StringBuilder<\/code> everywhere you might ask?<\/p>\n<p>Well, <code>StringBuilder<\/code> is an overhead if you need to concatenate just a few strings. It doesn&#8217;t pay off. But a few hundred or more, that&#8217;s when you should be thinking about using <code>StringBuilder<\/code> class.<\/p>\n<p>Let&#8217;s see how we can concatenate or rather append strings with the <code>StringBuilder.Append()<\/code> method:<\/p>\n<pre class=\"EnlighterJSRAW\" title=\"StringBuilder example\" data-enlighter-language=\"csharp\">StringBuilder stringBuilder = new StringBuilder();\r\n\r\nstringBuilder.Append(foo);\r\nstringBuilder.Append(\" \");\r\nstringBuilder.Append(bar);\r\n\r\nConsole.WriteLine(stringBuilder) \/\/ outputs \"Morning! Nice day for fishing, ain't it?\"<\/pre>\n<p>Again, this example is just to demonstrate how <code>StringBuilder<\/code> works. This is not the real case to use it. And you can see a bit overhead there, especially comparing it to something like string interpolation.<\/p>\n<h2><a id=\"conclusion\"><\/a>Conclusion<\/h2>\n<p>In this short tutorial, we&#8217;ve gone through the different ways of concatenating strings in C#. Mind you that these are not the only ways to do it since C# is pretty flexible, but these are the string-specific ways that were meant to be used for this purpose.<\/p>\n<p>Now that you know how to concatenate strings in multiple ways, go ahead and play around a bit. There are some pretty fun things you can pull off. Nice day for fishing, ain&#8217;t it?<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In this quick tutorial, we are going to talk about different ways to concatenate strings. Splitting and joining strings are commonly used operations in almost any real-world application, so let&#8217;s see how we can concatenate strings through some examples. We won&#8217;t cover methods that are not specifically meant for concatenating strings, like Enumerable.Aggregate() or any [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":53068,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_et_pb_use_builder":"","_et_pb_old_content":"","_et_gb_content_width":"","footnotes":""},"categories":[505,12],"tags":[10,242,704,702,701,706,703,705],"class_list":["post-53049","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-basic","category-csharp","tag-net","tag-string","tag-string-append","tag-string-concat","tag-string-concatenation","tag-string-format","tag-string-join","tag-string-merge","et-has-post-format-content","et_post_format-et-post-format-standard"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v24.7 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>A Few Different Ways to Concatenate Strings in C# - Code Maze<\/title>\n<meta name=\"description\" content=\"In this quick tutorial, we are going to talk about different ways to concatenate strings and write some examples that will help us understand them.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/code-maze.com\/different-ways-concatenate-strings-csharp\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"A Few Different Ways to Concatenate Strings in C# - Code Maze\" \/>\n<meta property=\"og:description\" content=\"In this quick tutorial, we are going to talk about different ways to concatenate strings and write some examples that will help us understand them.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/code-maze.com\/different-ways-concatenate-strings-csharp\/\" \/>\n<meta property=\"og:site_name\" content=\"Code Maze\" \/>\n<meta property=\"article:published_time\" content=\"2020-06-30T06:00:52+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2022-11-04T13:49:19+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/code-maze.com\/wp-content\/uploads\/2020\/06\/string-concatenate-featured.png\" \/>\n\t<meta property=\"og:image:width\" content=\"1100\" \/>\n\t<meta property=\"og:image:height\" content=\"620\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Vladimir Pecanac\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@https:\/\/twitter.com\/PecanacVladimir\" \/>\n<meta name=\"twitter:site\" content=\"@CodeMazeBlog\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Vladimir Pecanac\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"7 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":[\"Article\",\"BlogPosting\"],\"@id\":\"https:\/\/code-maze.com\/different-ways-concatenate-strings-csharp\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/code-maze.com\/different-ways-concatenate-strings-csharp\/\"},\"author\":{\"name\":\"Vladimir Pecanac\",\"@id\":\"https:\/\/code-maze.com\/#\/schema\/person\/50de31ad4e1992752e972e4715d93739\"},\"headline\":\"A Few Different Ways to Concatenate Strings in C#\",\"datePublished\":\"2020-06-30T06:00:52+00:00\",\"dateModified\":\"2022-11-04T13:49:19+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/code-maze.com\/different-ways-concatenate-strings-csharp\/\"},\"wordCount\":1175,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/code-maze.com\/#organization\"},\"image\":{\"@id\":\"https:\/\/code-maze.com\/different-ways-concatenate-strings-csharp\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/code-maze.com\/wp-content\/uploads\/2020\/06\/string-concatenate-featured.png\",\"keywords\":[\".NET\",\"String\",\"string append\",\"string concat\",\"string concatenation\",\"string format\",\"string join\",\"string merge\"],\"articleSection\":[\"Basic\",\"C#\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/code-maze.com\/different-ways-concatenate-strings-csharp\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/code-maze.com\/different-ways-concatenate-strings-csharp\/\",\"url\":\"https:\/\/code-maze.com\/different-ways-concatenate-strings-csharp\/\",\"name\":\"A Few Different Ways to Concatenate Strings in C# - Code Maze\",\"isPartOf\":{\"@id\":\"https:\/\/code-maze.com\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/code-maze.com\/different-ways-concatenate-strings-csharp\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/code-maze.com\/different-ways-concatenate-strings-csharp\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/code-maze.com\/wp-content\/uploads\/2020\/06\/string-concatenate-featured.png\",\"datePublished\":\"2020-06-30T06:00:52+00:00\",\"dateModified\":\"2022-11-04T13:49:19+00:00\",\"description\":\"In this quick tutorial, we are going to talk about different ways to concatenate strings and write some examples that will help us understand them.\",\"breadcrumb\":{\"@id\":\"https:\/\/code-maze.com\/different-ways-concatenate-strings-csharp\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/code-maze.com\/different-ways-concatenate-strings-csharp\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/code-maze.com\/different-ways-concatenate-strings-csharp\/#primaryimage\",\"url\":\"https:\/\/code-maze.com\/wp-content\/uploads\/2020\/06\/string-concatenate-featured.png\",\"contentUrl\":\"https:\/\/code-maze.com\/wp-content\/uploads\/2020\/06\/string-concatenate-featured.png\",\"width\":1100,\"height\":620,\"caption\":\"string concatenate featured\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/code-maze.com\/different-ways-concatenate-strings-csharp\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/code-maze.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"A Few Different Ways to Concatenate Strings in C#\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/code-maze.com\/#website\",\"url\":\"https:\/\/code-maze.com\/\",\"name\":\"Code Maze\",\"description\":\"Learn. Code. Succeed.\",\"publisher\":{\"@id\":\"https:\/\/code-maze.com\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/code-maze.com\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/code-maze.com\/#organization\",\"name\":\"Code Maze\",\"url\":\"https:\/\/code-maze.com\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/code-maze.com\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/code-maze.com\/wp-content\/uploads\/2020\/01\/Code-Maze-Only-Logo-Transparent-HRez.png\",\"contentUrl\":\"https:\/\/code-maze.com\/wp-content\/uploads\/2020\/01\/Code-Maze-Only-Logo-Transparent-HRez.png\",\"width\":3511,\"height\":3510,\"caption\":\"Code Maze\"},\"image\":{\"@id\":\"https:\/\/code-maze.com\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/x.com\/CodeMazeBlog\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/code-maze.com\/#\/schema\/person\/50de31ad4e1992752e972e4715d93739\",\"name\":\"Vladimir Pecanac\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/code-maze.com\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/code-maze.com\/wp-content\/uploads\/2016\/02\/profile_image-100x100.png\",\"contentUrl\":\"https:\/\/code-maze.com\/wp-content\/uploads\/2016\/02\/profile_image-100x100.png\",\"caption\":\"Vladimir Pecanac\"},\"description\":\"Hi, my name is Vladimir Pecanac, and I am a full-time .NET developer and DevOps enthusiast. I created this blog so I can share the things I learn in the hope of both helping others and deepening my own knowledge of the topics I write about. The best way to learn is to teach.\",\"sameAs\":[\"https:\/\/www.linkedin.com\/in\/vladimir-pecanac\/\",\"https:\/\/x.com\/https:\/\/twitter.com\/PecanacVladimir\"],\"url\":\"https:\/\/code-maze.com\/author\/codemaze_blog\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"A Few Different Ways to Concatenate Strings in C# - Code Maze","description":"In this quick tutorial, we are going to talk about different ways to concatenate strings and write some examples that will help us understand them.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/code-maze.com\/different-ways-concatenate-strings-csharp\/","og_locale":"en_US","og_type":"article","og_title":"A Few Different Ways to Concatenate Strings in C# - Code Maze","og_description":"In this quick tutorial, we are going to talk about different ways to concatenate strings and write some examples that will help us understand them.","og_url":"https:\/\/code-maze.com\/different-ways-concatenate-strings-csharp\/","og_site_name":"Code Maze","article_published_time":"2020-06-30T06:00:52+00:00","article_modified_time":"2022-11-04T13:49:19+00:00","og_image":[{"width":1100,"height":620,"url":"https:\/\/code-maze.com\/wp-content\/uploads\/2020\/06\/string-concatenate-featured.png","type":"image\/png"}],"author":"Vladimir Pecanac","twitter_card":"summary_large_image","twitter_creator":"@https:\/\/twitter.com\/PecanacVladimir","twitter_site":"@CodeMazeBlog","twitter_misc":{"Written by":"Vladimir Pecanac","Est. reading time":"7 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":["Article","BlogPosting"],"@id":"https:\/\/code-maze.com\/different-ways-concatenate-strings-csharp\/#article","isPartOf":{"@id":"https:\/\/code-maze.com\/different-ways-concatenate-strings-csharp\/"},"author":{"name":"Vladimir Pecanac","@id":"https:\/\/code-maze.com\/#\/schema\/person\/50de31ad4e1992752e972e4715d93739"},"headline":"A Few Different Ways to Concatenate Strings in C#","datePublished":"2020-06-30T06:00:52+00:00","dateModified":"2022-11-04T13:49:19+00:00","mainEntityOfPage":{"@id":"https:\/\/code-maze.com\/different-ways-concatenate-strings-csharp\/"},"wordCount":1175,"commentCount":0,"publisher":{"@id":"https:\/\/code-maze.com\/#organization"},"image":{"@id":"https:\/\/code-maze.com\/different-ways-concatenate-strings-csharp\/#primaryimage"},"thumbnailUrl":"https:\/\/code-maze.com\/wp-content\/uploads\/2020\/06\/string-concatenate-featured.png","keywords":[".NET","String","string append","string concat","string concatenation","string format","string join","string merge"],"articleSection":["Basic","C#"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/code-maze.com\/different-ways-concatenate-strings-csharp\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/code-maze.com\/different-ways-concatenate-strings-csharp\/","url":"https:\/\/code-maze.com\/different-ways-concatenate-strings-csharp\/","name":"A Few Different Ways to Concatenate Strings in C# - Code Maze","isPartOf":{"@id":"https:\/\/code-maze.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/code-maze.com\/different-ways-concatenate-strings-csharp\/#primaryimage"},"image":{"@id":"https:\/\/code-maze.com\/different-ways-concatenate-strings-csharp\/#primaryimage"},"thumbnailUrl":"https:\/\/code-maze.com\/wp-content\/uploads\/2020\/06\/string-concatenate-featured.png","datePublished":"2020-06-30T06:00:52+00:00","dateModified":"2022-11-04T13:49:19+00:00","description":"In this quick tutorial, we are going to talk about different ways to concatenate strings and write some examples that will help us understand them.","breadcrumb":{"@id":"https:\/\/code-maze.com\/different-ways-concatenate-strings-csharp\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/code-maze.com\/different-ways-concatenate-strings-csharp\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/code-maze.com\/different-ways-concatenate-strings-csharp\/#primaryimage","url":"https:\/\/code-maze.com\/wp-content\/uploads\/2020\/06\/string-concatenate-featured.png","contentUrl":"https:\/\/code-maze.com\/wp-content\/uploads\/2020\/06\/string-concatenate-featured.png","width":1100,"height":620,"caption":"string concatenate featured"},{"@type":"BreadcrumbList","@id":"https:\/\/code-maze.com\/different-ways-concatenate-strings-csharp\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/code-maze.com\/"},{"@type":"ListItem","position":2,"name":"A Few Different Ways to Concatenate Strings in C#"}]},{"@type":"WebSite","@id":"https:\/\/code-maze.com\/#website","url":"https:\/\/code-maze.com\/","name":"Code Maze","description":"Learn. Code. Succeed.","publisher":{"@id":"https:\/\/code-maze.com\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/code-maze.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/code-maze.com\/#organization","name":"Code Maze","url":"https:\/\/code-maze.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/code-maze.com\/#\/schema\/logo\/image\/","url":"https:\/\/code-maze.com\/wp-content\/uploads\/2020\/01\/Code-Maze-Only-Logo-Transparent-HRez.png","contentUrl":"https:\/\/code-maze.com\/wp-content\/uploads\/2020\/01\/Code-Maze-Only-Logo-Transparent-HRez.png","width":3511,"height":3510,"caption":"Code Maze"},"image":{"@id":"https:\/\/code-maze.com\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/x.com\/CodeMazeBlog"]},{"@type":"Person","@id":"https:\/\/code-maze.com\/#\/schema\/person\/50de31ad4e1992752e972e4715d93739","name":"Vladimir Pecanac","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/code-maze.com\/#\/schema\/person\/image\/","url":"https:\/\/code-maze.com\/wp-content\/uploads\/2016\/02\/profile_image-100x100.png","contentUrl":"https:\/\/code-maze.com\/wp-content\/uploads\/2016\/02\/profile_image-100x100.png","caption":"Vladimir Pecanac"},"description":"Hi, my name is Vladimir Pecanac, and I am a full-time .NET developer and DevOps enthusiast. I created this blog so I can share the things I learn in the hope of both helping others and deepening my own knowledge of the topics I write about. The best way to learn is to teach.","sameAs":["https:\/\/www.linkedin.com\/in\/vladimir-pecanac\/","https:\/\/x.com\/https:\/\/twitter.com\/PecanacVladimir"],"url":"https:\/\/code-maze.com\/author\/codemaze_blog\/"}]}},"_links":{"self":[{"href":"https:\/\/code-maze.com\/wp-json\/wp\/v2\/posts\/53049","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/code-maze.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/code-maze.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/code-maze.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/code-maze.com\/wp-json\/wp\/v2\/comments?post=53049"}],"version-history":[{"count":3,"href":"https:\/\/code-maze.com\/wp-json\/wp\/v2\/posts\/53049\/revisions"}],"predecessor-version":[{"id":76567,"href":"https:\/\/code-maze.com\/wp-json\/wp\/v2\/posts\/53049\/revisions\/76567"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/code-maze.com\/wp-json\/wp\/v2\/media\/53068"}],"wp:attachment":[{"href":"https:\/\/code-maze.com\/wp-json\/wp\/v2\/media?parent=53049"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/code-maze.com\/wp-json\/wp\/v2\/categories?post=53049"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/code-maze.com\/wp-json\/wp\/v2\/tags?post=53049"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}