CS
cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
/* These codes are to help me practice writing concatenated string & value combinations to the console.
They are meant for my own personal understanding: through variations in the code and trial and error,
I hope to better understand the limitations and applications. Given comments are notes I made in the process */
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace SoloLearn
{
class Program
{
static void Main(string[] args)
{
// 1) Using the correct syntax proposed in lesson '4.1 Printing text', using variable placeholders
int n = 5;
int m = n + 1;
Console.WriteLine("n = {0}; m = {1}", n, m);
// Output: "n = 5; m = 6". - Note lack of space between 6 and the ';'.
// 2) Using the syntax proposed in 4.1 incorrectly, duplicating the placeholder
int e = 8;
int f = 2 * e;
Console.WriteLine("e = {0} ; f = {0}", e, f);
/* Output: "e = 8; f = 8", instead of "f = 16".
Apparently, the {0} is still used with the value of e. */
Enter to Rename, Shift+Enter to Preview
OUTPUT
Run