Difference between revisions of "Concatenation"

esse quam videri
Jump to: navigation, search
(Relevance)
Line 2: Line 2:
  
 
=Relevance=
 
=Relevance=
*[[string]]
+
This is useful for putting data together to dipslay!
  
 
=Explanation=
 
=Explanation=
Line 10: Line 10:
  
 
=Example=
 
=Example=
{| class="ConcatTable"
+
<syntaxhighlight lang ="csharp">
!Str1
+
string a = "abc";
!+
+
string b = "def";
!Str2
+
string c = "123";
!Result
+
 
|-
+
int i = 123;
|"abc"
+
int j = 45;
| +
+
float k = 6.34f;
|"def"
+
 
|"abcdef"
+
string result1 = a + b; // result1 = "abcdef"
|-
+
string result2 = a + i; // result2 = "abc123"
|"abc"
+
string result3 = i + a; // result3 = "123abc"
| +
+
string result4 = c + i; // result4 = "123123"
|"123"
+
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
|"abc123"
 
|-
 
|"123"
 
| +
 
|"abc"
 
|"123abc"
 
|-
 
|"123"
 
| +
 
|"123"
 
|"123123"
 
|-
 
|"40"
 
| +
 
|"0.17"
 
|"400.17"
 
|-
 
|}
 
  
 +
/*
 +
"abc" + "def" = "abcdef"
 +
“abc” + 123 = “abc123”
 +
123 + “abc” = “123abc”
 +
“123” + 123 = “123123”
 +
45 + 6.34f = "456.34"
 +
*/
 +
</syntaxhighlight>
 
=Resources=
 
=Resources=
 
== See also ==
 
== See also ==
  
 +
*[[string]]
 
* [[Composite Formatting]]
 
* [[Composite Formatting]]
 
* [[Interpolated Formatting]]
 
* [[Interpolated Formatting]]

Revision as of 20:56, 19 June 2019

Definition

Relevance

This is useful for putting data together to dipslay!

Explanation

It is a way of making a new word (or String), by putting together two other strings.

Class Diagram

Example

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

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

Resources

See also

Notes

External Links