From 4d3d212a00a3f75b5743b43c5cdd547c1038fe2f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Almantas=20Karpavi=C4=8Dius?= Date: Sat, 11 Jan 2020 20:13:00 +0200 Subject: [PATCH 1/5] Fresh projects --- Bootcamp.sln | 24 +++++++++---------- .../BootCamp.Chapter1.csproj} | 0 .../Program.cs | 3 +-- .../BootCamp.Chapter1.Tests.csproj} | 2 +- .../UnitTest1.cs | 2 +- 5 files changed, 15 insertions(+), 16 deletions(-) rename Src/{BootCamp.Chapter/BootCamp.Chapter.csproj => BootCamp.Chapter1/BootCamp.Chapter1.csproj} (100%) rename Src/{BootCamp.Chapter => BootCamp.Chapter1}/Program.cs (60%) rename Tests/{BootCamp.Chapter.Tests/BootCamp.Chapter.Tests.csproj => BootCamp.Chapter1.Tests/BootCamp.Chapter1.Tests.csproj} (85%) rename Tests/{BootCamp.Chapter.Tests => BootCamp.Chapter1.Tests}/UnitTest1.cs (85%) diff --git a/Bootcamp.sln b/Bootcamp.sln index 6abd07798..5e968a8c5 100644 --- a/Bootcamp.sln +++ b/Bootcamp.sln @@ -7,9 +7,9 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Src", "Src", "{3E67C921-D34 EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Tests", "Tests", "{7559227A-AC63-40F9-B43A-BF1D3CB352D6}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BootCamp.Chapter", "Src\BootCamp.Chapter\BootCamp.Chapter.csproj", "{AD4B9DF0-A466-44FE-ADB8-D16BE20E6A37}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BootCamp.Chapter1.Tests", "Tests\BootCamp.Chapter1.Tests\BootCamp.Chapter1.Tests.csproj", "{AF2F380C-7A0D-4328-9CF5-2D7E9A2051F8}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BootCamp.Chapter.Tests", "Tests\BootCamp.Chapter.Tests\BootCamp.Chapter.Tests.csproj", "{955C76C7-582C-4C12-A253-0551A59E630A}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BootCamp.Chapter1", "Src\BootCamp.Chapter1\BootCamp.Chapter1.csproj", "{BAEFB31B-57F6-4100-A9D1-AF01BFD5EB2D}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -17,21 +17,21 @@ Global Release|Any CPU = Release|Any CPU EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution - {AD4B9DF0-A466-44FE-ADB8-D16BE20E6A37}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {AD4B9DF0-A466-44FE-ADB8-D16BE20E6A37}.Debug|Any CPU.Build.0 = Debug|Any CPU - {AD4B9DF0-A466-44FE-ADB8-D16BE20E6A37}.Release|Any CPU.ActiveCfg = Release|Any CPU - {AD4B9DF0-A466-44FE-ADB8-D16BE20E6A37}.Release|Any CPU.Build.0 = Release|Any CPU - {955C76C7-582C-4C12-A253-0551A59E630A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {955C76C7-582C-4C12-A253-0551A59E630A}.Debug|Any CPU.Build.0 = Debug|Any CPU - {955C76C7-582C-4C12-A253-0551A59E630A}.Release|Any CPU.ActiveCfg = Release|Any CPU - {955C76C7-582C-4C12-A253-0551A59E630A}.Release|Any CPU.Build.0 = Release|Any CPU + {AF2F380C-7A0D-4328-9CF5-2D7E9A2051F8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {AF2F380C-7A0D-4328-9CF5-2D7E9A2051F8}.Debug|Any CPU.Build.0 = Debug|Any CPU + {AF2F380C-7A0D-4328-9CF5-2D7E9A2051F8}.Release|Any CPU.ActiveCfg = Release|Any CPU + {AF2F380C-7A0D-4328-9CF5-2D7E9A2051F8}.Release|Any CPU.Build.0 = Release|Any CPU + {BAEFB31B-57F6-4100-A9D1-AF01BFD5EB2D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {BAEFB31B-57F6-4100-A9D1-AF01BFD5EB2D}.Debug|Any CPU.Build.0 = Debug|Any CPU + {BAEFB31B-57F6-4100-A9D1-AF01BFD5EB2D}.Release|Any CPU.ActiveCfg = Release|Any CPU + {BAEFB31B-57F6-4100-A9D1-AF01BFD5EB2D}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection GlobalSection(NestedProjects) = preSolution - {AD4B9DF0-A466-44FE-ADB8-D16BE20E6A37} = {3E67C921-D341-42FB-9934-B03C05A28BEB} - {955C76C7-582C-4C12-A253-0551A59E630A} = {7559227A-AC63-40F9-B43A-BF1D3CB352D6} + {AF2F380C-7A0D-4328-9CF5-2D7E9A2051F8} = {7559227A-AC63-40F9-B43A-BF1D3CB352D6} + {BAEFB31B-57F6-4100-A9D1-AF01BFD5EB2D} = {3E67C921-D341-42FB-9934-B03C05A28BEB} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {5969FA83-B2F9-4714-8336-EEBBDA71F6FF} diff --git a/Src/BootCamp.Chapter/BootCamp.Chapter.csproj b/Src/BootCamp.Chapter1/BootCamp.Chapter1.csproj similarity index 100% rename from Src/BootCamp.Chapter/BootCamp.Chapter.csproj rename to Src/BootCamp.Chapter1/BootCamp.Chapter1.csproj diff --git a/Src/BootCamp.Chapter/Program.cs b/Src/BootCamp.Chapter1/Program.cs similarity index 60% rename from Src/BootCamp.Chapter/Program.cs rename to Src/BootCamp.Chapter1/Program.cs index dc9c6bf6e..6fe660d5d 100644 --- a/Src/BootCamp.Chapter/Program.cs +++ b/Src/BootCamp.Chapter1/Program.cs @@ -1,12 +1,11 @@ using System; -namespace BootCamp.Chapter +namespace BootCamp.Chapter1 { class Program { static void Main(string[] args) { - Console.WriteLine("Hello World!"); } } } diff --git a/Tests/BootCamp.Chapter.Tests/BootCamp.Chapter.Tests.csproj b/Tests/BootCamp.Chapter1.Tests/BootCamp.Chapter1.Tests.csproj similarity index 85% rename from Tests/BootCamp.Chapter.Tests/BootCamp.Chapter.Tests.csproj rename to Tests/BootCamp.Chapter1.Tests/BootCamp.Chapter1.Tests.csproj index 1a4844f37..7e1e6fa47 100644 --- a/Tests/BootCamp.Chapter.Tests/BootCamp.Chapter.Tests.csproj +++ b/Tests/BootCamp.Chapter1.Tests/BootCamp.Chapter1.Tests.csproj @@ -14,7 +14,7 @@ - + diff --git a/Tests/BootCamp.Chapter.Tests/UnitTest1.cs b/Tests/BootCamp.Chapter1.Tests/UnitTest1.cs similarity index 85% rename from Tests/BootCamp.Chapter.Tests/UnitTest1.cs rename to Tests/BootCamp.Chapter1.Tests/UnitTest1.cs index 024efc683..c49a24f90 100644 --- a/Tests/BootCamp.Chapter.Tests/UnitTest1.cs +++ b/Tests/BootCamp.Chapter1.Tests/UnitTest1.cs @@ -1,6 +1,6 @@ using Xunit; -namespace BootCamp.Chapter.Tests +namespace BootCamp.Chapter1.Tests { // You don't have to be here for a long time. public class UnitTest1 From 0505ca07bb0f172a496f16585c20427c38d8f6fc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Almantas=20Karpavi=C4=8Dius?= Date: Sat, 11 Jan 2020 23:08:38 +0200 Subject: [PATCH 2/5] Lesson 1 stream material --- Src/BootCamp.Chapter1/Program.cs | 100 +++++++++++++++++++++++++++++++ 1 file changed, 100 insertions(+) diff --git a/Src/BootCamp.Chapter1/Program.cs b/Src/BootCamp.Chapter1/Program.cs index 6fe660d5d..92f59d665 100644 --- a/Src/BootCamp.Chapter1/Program.cs +++ b/Src/BootCamp.Chapter1/Program.cs @@ -1,11 +1,111 @@ using System; +using System.ComponentModel; namespace BootCamp.Chapter1 { class Program { + // In C# comments are with "//" + /* + This is a multiline comment. It start with + "/*" and ends with "* /" (no space) + */ + // Comments are just text which will taken as an instruction, thus will be skipped. + // Running with VS menu will put application in debug mode. + // Running with "ctrl + F5" will put it in release mode. static void Main(string[] args) { + // PascalCase (first letter is capital and all other words start with capital letter) + // camelCase (first letter is non-capital and all other words start with capital letter) + + // for variable names we can use: [aA-zZ], [0-9], _ + + // whole numbers: + // 32 bit + int myAge = 25; + + // 64 bit + long lightyears = 9999999999999999; + + // numbers with a fraction: + // floats are fast, 32 bit + float weight = 80.5f; + float height = 201.1f; + + // double precision compared: + // doubles are slower, 64 bit + // double is a default number type with fraction + double number6 = 2.5; + + // decimal is explicitly used for money and scientific calculations + // (decimal) means that from double to decimal + // 128 bit + decimal money = (decimal)10000000000000000000000.156465465465465464654654654654654654654654; + + // string is used to store text: + // double quotes ("") + string myName = "Kaisinel"; + + // char is used for storing a single symbol + // single quotes ('') + char firstLetter = 'K'; + + // for binary types (logical- true or false) we use boolean. + bool isItFirstLesson = true; + bool isItLastLesson = false; + + // var can be used as an alternative to define a variable with a type. + var variablesDone = "Variables done"; + var timeNow = 10; + // doesn't work -var unknown; + Console.WriteLine(myName); + + // We can add any two nubmers together + int sum = 1 + 5; // 6 + int sumx2 = sum + sum; // 12 + sumx2 = sumx2 * 2; // 24 + var sumMoreFloat = sumx2 + 2.0f; + var sumMoreDecimal = (decimal)sumMoreFloat + (decimal)1.000001; + Console.WriteLine(sumMoreDecimal); + + // We can add string and other primitives to a string and so they all become string: + var greetings = "Hello world!"; + var fullGreeting = myName + ", " + greetings; + var fullGreetingTimes = fullGreeting + 1; + Console.WriteLine(fullGreetingTimes); + + // We can add char, int and char, etc + var a = 'a'; + Console.WriteLine(a + " is " + (int)a); + var b = 'b'; + Console.WriteLine(b + " is " + (int)b); + var aAndB = a + b; + Console.WriteLine("a + b =" + aAndB); + Console.WriteLine("What symbol goes after 'Z' in ascii?"); + var afterZ = Convert.ToChar('Z' + 1); + Console.WriteLine("Answer: " + afterZ); + + // we cannot substract string + // how many letters in alphabet: + Console.WriteLine("Letters in alphabet: " + ('z' - 'a') + 1); + + // you can only multiply and divide number + // dividing an integer from an integer ignores a fraction part. + var divisionResult = 1 / 100; + Console.WriteLine(divisionResult); + // dividing an integer from a number with a fraction keeps a fraction part. + var divisionResultFraction = 1 / 100.0; + Console.WriteLine(divisionResultFraction); + var hundred = 100; + var hundredHundreds = hundred * 100.0f; + Console.WriteLine(hundredHundreds); + + // Values that don't change, should be used as a constant. + const double pi = 3.1415926535; + + Console.Write("Input your name: "); + string name = Console.ReadLine(); + Console.WriteLine("Hello again, " + name); } } } From a9558e87f3bb9c2b12414013d7aaf1880fb55875 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Almantas=20Karpavi=C4=8Dius?= Date: Sun, 12 Jan 2020 00:31:10 +0200 Subject: [PATCH 3/5] Extra comments added --- Src/BootCamp.Chapter1/Program.cs | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/Src/BootCamp.Chapter1/Program.cs b/Src/BootCamp.Chapter1/Program.cs index 92f59d665..267b897a6 100644 --- a/Src/BootCamp.Chapter1/Program.cs +++ b/Src/BootCamp.Chapter1/Program.cs @@ -1,8 +1,10 @@ -using System; -using System.ComponentModel; +// Ignore using System; for now +using System; +// Ignore namespace BootCamp.Chapter1 for now namespace BootCamp.Chapter1 { + // Ignore class Program for now. class Program { // In C# comments are with "//" @@ -13,6 +15,10 @@ This is a multiline comment. It start with // Comments are just text which will taken as an instruction, thus will be skipped. // Running with VS menu will put application in debug mode. // Running with "ctrl + F5" will put it in release mode. + + // Every function has some entry point. + // Starting (entry) point of a console application is Main. + // Write code below, within Main. static void Main(string[] args) { // PascalCase (first letter is capital and all other words start with capital letter) @@ -74,14 +80,17 @@ static void Main(string[] args) var fullGreetingTimes = fullGreeting + 1; Console.WriteLine(fullGreetingTimes); - // We can add char, int and char, etc var a = 'a'; + // char + string = string + // (int)char = ascii Console.WriteLine(a + " is " + (int)a); var b = 'b'; Console.WriteLine(b + " is " + (int)b); + // char + char = int var aAndB = a + b; Console.WriteLine("a + b =" + aAndB); Console.WriteLine("What symbol goes after 'Z' in ascii?"); + // char + int = int var afterZ = Convert.ToChar('Z' + 1); Console.WriteLine("Answer: " + afterZ); @@ -104,6 +113,7 @@ static void Main(string[] args) const double pi = 3.1415926535; Console.Write("Input your name: "); + // Read line of text from console. string name = Console.ReadLine(); Console.WriteLine("Hello again, " + name); } From 3d87c0586a4214a8ba3017a60f777b6889b73151 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Almantas=20Karpavi=C4=8Dius?= Date: Sun, 23 Feb 2020 22:44:23 +0200 Subject: [PATCH 4/5] Proper title --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index a323b6bb3..5eb433967 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# CSharp-From-Zero-To-Hero +# C#: From Zero To Hero [![Build Status](https://dev.azure.com/almantusk/From-Zero-To-Hero/_apis/build/status/Almantask.CSharp-From-Zero-To-Hero?branchName=master)](https://dev.azure.com/almantusk/From-Zero-To-Hero/_build/latest?definitionId=5&branchName=master) [![Codacy Badge](https://api.codacy.com/project/badge/Grade/a358adf21c2442cd91a4827a50213ff1)](https://www.codacy.com/manual/Almantask/CSharp-From-Zero-To-Hero?utm_source=github.com&utm_medium=referral&utm_content=Almantask/CSharp-From-Zero-To-Hero&utm_campaign=Badge_Grade) C# boot camp From 6624fbe2ab5817c6d908bae8b00af233fc5702c9 Mon Sep 17 00:00:00 2001 From: 7IronSnow7 Date: Fri, 22 Sep 2023 19:57:05 -0400 Subject: [PATCH 5/5] Update Program.cs Line 69 "nubmers" changed to "numbers".