From ad54e970d02715dc979fbddd938ebfd066ccd5a0 Mon Sep 17 00:00:00 2001 From: Courtney Frey Date: Tue, 11 Oct 2022 15:02:26 -0500 Subject: [PATCH 1/4] update to dotnet 6 --- csharp-web-dev-exceptions/Program.cs | 68 ++++++++++++++++++- .../csharp-web-dev-exceptions.csproj | 2 +- .../csharp-web-dev-exceptions.sln | 25 +++++++ 3 files changed, 92 insertions(+), 3 deletions(-) create mode 100644 csharp-web-dev-exceptions/csharp-web-dev-exceptions.sln diff --git a/csharp-web-dev-exceptions/Program.cs b/csharp-web-dev-exceptions/Program.cs index 7292251..b26c6a6 100644 --- a/csharp-web-dev-exceptions/Program.cs +++ b/csharp-web-dev-exceptions/Program.cs @@ -7,29 +7,93 @@ namespace csharp_web_dev_lsn9exceptions { class Program { - /* + static double Divide(double x, double y) { // Write your code here! + //TODO: Remove this if/else once working + if (y == 0.0) + { + throw new ArgumentOutOfRangeException("y", "You cannot divide by zero!"); + } + else + { + return x / y; + } + } static int CheckFileExtension(string fileName) { // Write your code here! + //TODO: Remove this if/else once working + if (fileName == null || fileName == "") + { + throw new ArgumentNullException("fileName", "Student did not submit any work!"); + } + else + { + if (fileName.Substring(fileName.Length - 3, 3) == ".cs") + { + return 1; + } + else + { + return 0; + } + } + } - */ + static void Main(string[] args) { // Test out your Divide() function here! // Test out your CheckFileExtension() function here! + /* + Dictionary students = new Dictionary(); + students.Add("Carl", "Program.cs"); + students.Add("Brad", ""); + students.Add("Elizabeth", "MyCode.cs"); + students.Add("Stefanie", "CoolProgram.cs"); + */ + + double a = 9.9; + double b = 0.0; + Console.WriteLine(a); + Console.WriteLine(b); + + try + { + Divide(a, b); + } + catch (ArgumentOutOfRangeException e) + { + Console.WriteLine(e.Message); + } + + // Help out the teacher! Dictionary students = new Dictionary(); students.Add("Carl", "Program.cs"); students.Add("Brad", ""); students.Add("Elizabeth", "MyCode.cs"); students.Add("Stefanie", "CoolProgram.cs"); + foreach (KeyValuePair student in students) + { + try + { + Console.WriteLine(student.Key); + CheckFileExtension(student.Value); + } + catch (ArgumentNullException n) + { + Console.WriteLine(n.Message); + } + } + + } } diff --git a/csharp-web-dev-exceptions/csharp-web-dev-exceptions.csproj b/csharp-web-dev-exceptions/csharp-web-dev-exceptions.csproj index 66590b9..5dc6052 100644 --- a/csharp-web-dev-exceptions/csharp-web-dev-exceptions.csproj +++ b/csharp-web-dev-exceptions/csharp-web-dev-exceptions.csproj @@ -2,7 +2,7 @@ Exe - netcoreapp3.1 + net6.0 csharp_web_dev_lsn9exceptions diff --git a/csharp-web-dev-exceptions/csharp-web-dev-exceptions.sln b/csharp-web-dev-exceptions/csharp-web-dev-exceptions.sln new file mode 100644 index 0000000..45cb15d --- /dev/null +++ b/csharp-web-dev-exceptions/csharp-web-dev-exceptions.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 16 +VisualStudioVersion = 25.0.1703.6 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "csharp-web-dev-exceptions", "csharp-web-dev-exceptions.csproj", "{B1E613FF-9A83-4875-81AD-8537DDDFCE0E}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {B1E613FF-9A83-4875-81AD-8537DDDFCE0E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {B1E613FF-9A83-4875-81AD-8537DDDFCE0E}.Debug|Any CPU.Build.0 = Debug|Any CPU + {B1E613FF-9A83-4875-81AD-8537DDDFCE0E}.Release|Any CPU.ActiveCfg = Release|Any CPU + {B1E613FF-9A83-4875-81AD-8537DDDFCE0E}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {28D40D3E-4831-4F20-BC01-19F7A776CFFF} + EndGlobalSection +EndGlobal From 0a852f2fc325c6ff8ae1315299e2b90edc5d3fa2 Mon Sep 17 00:00:00 2001 From: Courtney Frey Date: Tue, 11 Oct 2022 15:03:56 -0500 Subject: [PATCH 2/4] dotnet 6 update --- csharp-web-dev-exceptions/Program.cs | 72 ++-------------------------- 1 file changed, 4 insertions(+), 68 deletions(-) diff --git a/csharp-web-dev-exceptions/Program.cs b/csharp-web-dev-exceptions/Program.cs index b26c6a6..01acdb5 100644 --- a/csharp-web-dev-exceptions/Program.cs +++ b/csharp-web-dev-exceptions/Program.cs @@ -7,43 +7,17 @@ namespace csharp_web_dev_lsn9exceptions { class Program { - + /* static double Divide(double x, double y) { // Write your code here! - //TODO: Remove this if/else once working - if (y == 0.0) - { - throw new ArgumentOutOfRangeException("y", "You cannot divide by zero!"); - } - else - { - return x / y; - } - } static int CheckFileExtension(string fileName) { // Write your code here! - //TODO: Remove this if/else once working - if (fileName == null || fileName == "") - { - throw new ArgumentNullException("fileName", "Student did not submit any work!"); - } - else - { - if (fileName.Substring(fileName.Length - 3, 3) == ".cs") - { - return 1; - } - else - { - return 0; - } - } - } + */ static void Main(string[] args) @@ -51,50 +25,12 @@ static void Main(string[] args) // Test out your Divide() function here! // Test out your CheckFileExtension() function here! - /* - Dictionary students = new Dictionary(); - students.Add("Carl", "Program.cs"); - students.Add("Brad", ""); - students.Add("Elizabeth", "MyCode.cs"); - students.Add("Stefanie", "CoolProgram.cs"); - */ - - double a = 9.9; - double b = 0.0; - Console.WriteLine(a); - Console.WriteLine(b); - - try - { - Divide(a, b); - } - catch (ArgumentOutOfRangeException e) - { - Console.WriteLine(e.Message); - } - - // Help out the teacher! + Dictionary students = new Dictionary(); students.Add("Carl", "Program.cs"); students.Add("Brad", ""); students.Add("Elizabeth", "MyCode.cs"); - students.Add("Stefanie", "CoolProgram.cs"); - - foreach (KeyValuePair student in students) - { - try - { - Console.WriteLine(student.Key); - CheckFileExtension(student.Value); - } - catch (ArgumentNullException n) - { - Console.WriteLine(n.Message); - } - } - - - + students.Add("Stefanie", "CoolProgram.cs"); } } } From 48671bcef99ab1dff4276c7571e202abbffc484b Mon Sep 17 00:00:00 2001 From: Courtney Frey Date: Tue, 11 Oct 2022 15:20:38 -0500 Subject: [PATCH 3/4] dotnet 6 update --- .../TemperatureExceptions.csproj | 2 +- .../TemperatureExceptions.sln | 25 +++++++++++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) create mode 100644 TemperatureExceptions/TemperatureExceptions.sln diff --git a/TemperatureExceptions/TemperatureExceptions.csproj b/TemperatureExceptions/TemperatureExceptions.csproj index c73e0d1..41f1d5a 100644 --- a/TemperatureExceptions/TemperatureExceptions.csproj +++ b/TemperatureExceptions/TemperatureExceptions.csproj @@ -2,7 +2,7 @@ Exe - netcoreapp3.1 + net6.0 diff --git a/TemperatureExceptions/TemperatureExceptions.sln b/TemperatureExceptions/TemperatureExceptions.sln new file mode 100644 index 0000000..587cdee --- /dev/null +++ b/TemperatureExceptions/TemperatureExceptions.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 16 +VisualStudioVersion = 25.0.1703.6 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TemperatureExceptions", "TemperatureExceptions.csproj", "{8F9A99A5-7F16-4F7C-A986-894070313962}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {8F9A99A5-7F16-4F7C-A986-894070313962}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {8F9A99A5-7F16-4F7C-A986-894070313962}.Debug|Any CPU.Build.0 = Debug|Any CPU + {8F9A99A5-7F16-4F7C-A986-894070313962}.Release|Any CPU.ActiveCfg = Release|Any CPU + {8F9A99A5-7F16-4F7C-A986-894070313962}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {6B12E250-6309-4A9A-8C36-5FE1F8EBCAB7} + EndGlobalSection +EndGlobal From 956005348154482f616a0b7e91a15c9d30a9d80f Mon Sep 17 00:00:00 2001 From: Courtney Frey Date: Tue, 11 Oct 2022 16:10:58 -0500 Subject: [PATCH 4/4] updated to dotnet 6 --- .../Unit1-TempExceptions/Program.cs | 1 + .../Unit1-TempExceptions.csproj | 2 +- .../Unit1-TempExceptions.sln | 25 +++++++++++++++++++ 3 files changed, 27 insertions(+), 1 deletion(-) create mode 100644 Unit1-TempExceptions/Unit1-TempExceptions/Unit1-TempExceptions.sln diff --git a/Unit1-TempExceptions/Unit1-TempExceptions/Program.cs b/Unit1-TempExceptions/Unit1-TempExceptions/Program.cs index 0f7a3a6..b0d50be 100644 --- a/Unit1-TempExceptions/Unit1-TempExceptions/Program.cs +++ b/Unit1-TempExceptions/Unit1-TempExceptions/Program.cs @@ -1,6 +1,7 @@ using System; //Book examples for the Unit 1 C# Program +//to run program use terminal and type "dotnet run" namespace Unit1_TempExceptions { diff --git a/Unit1-TempExceptions/Unit1-TempExceptions/Unit1-TempExceptions.csproj b/Unit1-TempExceptions/Unit1-TempExceptions/Unit1-TempExceptions.csproj index 54b60a0..9846615 100644 --- a/Unit1-TempExceptions/Unit1-TempExceptions/Unit1-TempExceptions.csproj +++ b/Unit1-TempExceptions/Unit1-TempExceptions/Unit1-TempExceptions.csproj @@ -2,7 +2,7 @@ Exe - netcoreapp3.1 + net6.0 Unit1_TempExceptions diff --git a/Unit1-TempExceptions/Unit1-TempExceptions/Unit1-TempExceptions.sln b/Unit1-TempExceptions/Unit1-TempExceptions/Unit1-TempExceptions.sln new file mode 100644 index 0000000..d882a15 --- /dev/null +++ b/Unit1-TempExceptions/Unit1-TempExceptions/Unit1-TempExceptions.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 16 +VisualStudioVersion = 25.0.1703.6 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Unit1-TempExceptions", "Unit1-TempExceptions.csproj", "{2422319F-028E-443B-97E0-59EE71A3B07C}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {2422319F-028E-443B-97E0-59EE71A3B07C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {2422319F-028E-443B-97E0-59EE71A3B07C}.Debug|Any CPU.Build.0 = Debug|Any CPU + {2422319F-028E-443B-97E0-59EE71A3B07C}.Release|Any CPU.ActiveCfg = Release|Any CPU + {2422319F-028E-443B-97E0-59EE71A3B07C}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {F97D3ED4-ADFC-4D04-88BB-50DC8DBFE651} + EndGlobalSection +EndGlobal