Difference between revisions of "Concatenation"

esse quam videri
Jump to: navigation, search
(Relevance)
 
(3 intermediate revisions by 2 users not shown)
Line 1: Line 1:
 
=Definition=
 
=Definition=
 +
Combining elements end-to-end to form 1 combined result. In the case of computer programming, an element could be a string but the result is always saved to a string.
  
 
=Relevance=
 
=Relevance=
*[[string]]
+
*[[String]]
  
 
=Explanation=
 
=Explanation=
It is a way of making a new word (or String), by putting together two other strings.
+
It is a way of making a new string (or sentence), by putting together two or more elements.
 +
 
 +
'''How strings can be made:'''
 +
 
 +
<syntaxhighlight lang ="csharp">
 +
string a = "abc";
 +
string b = "def";
 +
string c = "123";
  
Class Diagram
+
int i = 123;
 +
int j = 45;
 +
float k = 6.34f;
  
=Example=
+
string result1 = a + b; // result1 = "abcdef"
{| class="ConcatTable"
+
string result2 = a + i; // result2 = "abc123"
!Str1
+
string result3 = i + a; // result3 = "123abc"
!+
+
string result4 = c + i; // result4 = "123123"
!Str2
+
string result5 = j + k; // result5 = "456.34" because even though both variables are numbers, because we are saving it as a string, it will concatinate instead of actually adding the numbers
!Result
+
string result6 = a + b + i; // result6 = "abcdef123" concatenation can also be with multiple elements, not just two elements
|-
 
|"abc"
 
| +
 
|"def"
 
|"abcdef"
 
|-
 
|"abc"
 
| +
 
|"123"
 
|"abc123"
 
|-
 
|"123"
 
| +
 
|"abc"
 
|"123abc"
 
|-
 
|"123"
 
| +
 
|"123"
 
|"123123"
 
|-
 
|"40"
 
| +
 
|"0.17"
 
|"400.17"
 
|-
 
|}
 
  
=Resources=
+
/*
 +
"abc" + "def" = "abcdef"
 +
“abc” + 123 = “abc123”
 +
123 + “abc” = “123abc”
 +
“123” + 123 = “123123”
 +
45 + 6.34f = "456.34"
 +
"abc" + "def" + 123 = "abcdef123"
 +
*/
 +
</syntaxhighlight>
 
== See also ==
 
== See also ==
  
 +
*[[string]]
 
* [[Composite Formatting]]
 
* [[Composite Formatting]]
 
* [[Interpolated Formatting]]
 
* [[Interpolated Formatting]]
 
==Notes==
 
 
 
==External Links==
 
 
  
  

Latest revision as of 15:54, 8 August 2019

Definition

Combining elements end-to-end to form 1 combined result. In the case of computer programming, an element could be a string but the result is always saved to a string.

Relevance

Explanation

It is a way of making a new string (or sentence), by putting together two or more elements.

How strings can be made:

string a = "abc";
string b = "def";
string c = "123";

int i = 123;
int j = 45;
float k = 6.34f;

string result1 = a + b; // result1 = "abcdef"
string result2 = a + i; // result2 = "abc123"
string result3 = i + a; // result3 = "123abc"
string result4 = c + i; // result4 = "123123"
string result5 = j + k; // result5 = "456.34" because even though both variables are numbers, because we are saving it as a string, it will concatinate instead of actually adding the numbers
string result6 = a + b + i; // result6 = "abcdef123" concatenation can also be with multiple elements, not just two elements

/*
"abc" + "def" = "abcdef"
“abc” + 123 = “abc123”
123 + “abc” = “123abc”
“123” + 123 = “123123”
45 + 6.34f = "456.34"
"abc" + "def" + 123 = "abcdef123"
*/

See also