-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathStringInterpolationSample.cs
29 lines (28 loc) · 1.16 KB
/
StringInterpolationSample.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
29
using System;
using System.Text;
namespace CodeSamples.SyntacticSugars
{
public class StringInterpolationSample : SampleExecute
{
public override void Execute()
{
Title("StringInterpolationSampleExecute");
int intVariable = 5;
string stringVariable = "some value";
double doubleVariable = Math.PI;
DateTime datetimeVariable = DateTime.Now;
StringBuilder sb = new StringBuilder();
//
sb.Append($"Integer = {intVariable}").Append(", ");
sb.Append($"String = {stringVariable}").Append(", ");
sb.Append($"Double (2 decimals) value = {doubleVariable:0.00}").Append(", ");
sb.Append($"Double (2 decimals, leading zeroes) value = {doubleVariable:000.00}").Append(", ");
sb.Append($"Double (5 decimals) = {doubleVariable:0.00000}").Append(", ");
sb.Append($"DateTime (dd.MM.yyyy) = {datetimeVariable:dd.MM.yyyy}").Append(", ");
sb.Append($"DateTime (yyyy-MM-dd) = {datetimeVariable:yyyy-MM-dd}");
//
Console.WriteLine(sb.ToString());
Finish();
}
}
}