mirror of
https://github.com/markjprice/cs11dotnet7.git
synced 2026-04-06 14:53:47 +00:00
Initial commit
This commit is contained in:
parent
d5bde3c775
commit
5fb8e6929b
33 changed files with 842 additions and 0 deletions
35
vscode/Chapter02/Formatting/Program.cs
Normal file
35
vscode/Chapter02/Formatting/Program.cs
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
using static System.Console;
|
||||
|
||||
int numberOfApples = 12;
|
||||
decimal pricePerApple = 0.35M;
|
||||
|
||||
WriteLine(
|
||||
format: "{0} apples costs {1:C}",
|
||||
arg0: numberOfApples,
|
||||
arg1: pricePerApple * numberOfApples);
|
||||
|
||||
string formatted = string.Format(
|
||||
format: "{0} apples costs {1:C}",
|
||||
arg0: numberOfApples,
|
||||
arg1: pricePerApple * numberOfApples);
|
||||
|
||||
//WriteToFile(formatted); // writes the string into a file
|
||||
|
||||
WriteLine($"{numberOfApples} apples costs {pricePerApple * numberOfApples:C}");
|
||||
|
||||
Write("Type your first name and press ENTER: ");
|
||||
string? firstName = ReadLine(); // nulls are expected
|
||||
|
||||
Write("Type your age and press ENTER: ");
|
||||
string age = ReadLine()!; // null won't be returned
|
||||
|
||||
WriteLine(
|
||||
$"Hello {firstName}, you look good for {age}.");
|
||||
|
||||
Write("Press any key combination: ");
|
||||
ConsoleKeyInfo key = ReadKey();
|
||||
WriteLine();
|
||||
WriteLine("Key: {0}, Char: {1}, Modifiers: {2}",
|
||||
arg0: key.Key,
|
||||
arg1: key.KeyChar,
|
||||
arg2: key.Modifiers);
|
||||
Loading…
Add table
Add a link
Reference in a new issue