Sep 13, 2024
string firstFriend = "Maria";
string
: Data type.firstFriend
: Variable name.Maria
: Value stored in the variable.;
: Semicolon denotes the end of the statement (similar to a period in a sentence).firstFriend
, f
).Console.WriteLine
to output strings.Console.WriteLine($"My friends are {firstFriend} and {secondFriend}");
$
: Indicates string interpolation.{}
are used to embed variable values within strings.+
operator.
"My friends are " + firstFriend + " and " + secondFriend;
firstFriend = firstFriend.Trim();
.Trim()
method.string firstFriend = " Maria ";
(with spaces).firstFriend = firstFriend.Trim();
to remove spaces.Console.WriteLine()
after trimming.