Learning Path Details
Foundation in C#: Debugging from Tim Corey
Description:
Module 3 of the Complete Foundation in C# Course Series, the focus is on debugging our applications, including use of breakpoints and exception handling. At the end of the module, we do a mini project to demonstrate what we have learned.
Key Takeaways:
We learn how to use the Visual Studio debugger to debug our applications, including the use of breakpoints, conditional breakpoints, and proper exception handling.
Technologies Learned:
- .NET;
- .NET Framework;
- .NET Framework 4.7.2;
- C#;
- Child Classes of the Exception Class;
- Exceptions (Class);
- Handling Exceptions;
- Multiple Catch statements;
- try/catch;
- try/catch/finally;
- Using Breakpoints;
- Visual Studio Debugger;
This learning resource was completed on 8/18/2021.
Find the Resource here:
Practice Projects
Advanced Breakpoints
Description:
The homework from the Lesson 5, Advanced Breakpoints, of Module 3, Debugging, of the Complete Foundation in C# Course Series from Tim Corey. We are to create a Console Application that loops from 1 to 100. Throw an exception on 73. Use a breakpoint to break before the breaking situation.
Technologies Used:
- .NET;
- .NET Framework;
- .NET Framework 4.8;
- C#;
Find the Project here:
https://github.com/Spartan-CSharp/Debugging-AdvancedBreakpoints
Code Snippet:
using System;
namespace ConsoleUI
{
internal class Program
{
private static void Main()
{
Looper();
_ = Console.ReadLine();
}
private static void Looper()
{
int total = 0;
for ( int i = 1; i <= 100; i++ )
{
total += i;
if ( i == 73 )
{
throw new Exception();
}
}
}
}
}
Advanced Exceptions
Description:
The homework from the Lesson 4, Advanced Exceptions, of Module 3, Debugging, of the Complete Foundation in C# Course Series from Tim Corey. We are to create a Console Application that throws an exception in a method that we can catch in the main method.
Technologies Used:
- .NET;
- .NET Framework;
- .NET Framework 4.8;
- C#;
- Console Application;
Find the Project here:
https://github.com/Spartan-CSharp/Debugging-AdvancedExceptions
Code Snippet:
using System;
namespace ConsoleUI
{
internal class Program
{
private static void Main()
{
try
{
ExceptionGenerator();
}
catch ( NotImplementedException ex )
{
Console.WriteLine("You did not implement a mathod.");
Console.WriteLine(ex);
}
catch ( Exception ex )
{
Console.WriteLine("A general exception occurred");
Console.WriteLine(ex);
}
finally
{
Console.WriteLine("Clean up code: I always run!");
}
_ = Console.ReadLine();
}
private static void ExceptionGenerator()
{
throw new NotImplementedException();
}
}
}
Handling Exceptions
Description:
The homework from the Lesson 3, Handling Exceptions, of Module 3, Debugging, of the Complete Foundation in C# Course Series from Tim Corey. We are to create a Console Application with a for loop that throws an exception after five iterations. Catch the exception.
Technologies Used:
- .NET;
- .NET Framework;
- .NET Framework 4.8;
- C#;
- Console Application;
Find the Project here:
https://github.com/Spartan-CSharp/Debugging-HandlingExceptions
Code Snippet:
using System;
namespace ConsoleUI
{
internal class Program
{
private static void Main()
{
int[] numbers = new int[] { 1, 42, 34, 56, 13 };
for ( int i = 0; i <= numbers.Length; i++ )
{
try
{
Console.WriteLine($"The number at position {i} is {numbers[i]}");
}
catch ( Exception ex )
{
Console.WriteLine("We had an error");
Console.WriteLine(ex);
}
}
_ = Console.ReadLine();
}
}
}
Using Breakpoints
Description:
The homework from the Lesson 2, Using Breakpoints, of Module 3, Debugging, of the Complete Foundation in C# Course Series from Tim Corey. We are to create a Console Application with a for loop that multiplies a number by five and adds it to the total each time. Step through the code.
Technologies Used:
- .NET;
- .NET Framework;
- .NET Framework 4.8;
- C#;
- Console Application;
Find the Project here:
https://github.com/Spartan-CSharp/Debugging-UsingBreakpoints
Code Snippet:
using System;
namespace ConsoleUI
{
internal class Program
{
private static void Main()
{
for ( int i = 1; i < 50; i *= 5 )
{
Console.WriteLine($"The value of i is {i}");
}
_ = Console.ReadLine();
}
}
}