Skip to content

C#

Version

Running C# on .NET 8.0

Supported languages

C#

Testing framework

xUnit v2.7.0

Special reminders and implementation details

csharp
using Xunit;

namespace Challenge
{
    public class HelloWorldTest
    {
        [Fact(DisplayName = "It should return 'Hello World!'")]
        public void TestHelloWorld()
        {
            Assert.Equal("Hello World!", HelloWorld.Hello());
        }
    }
}

Included libraries

How to debug

Debugging C# code is essential for every developer. One of the simplest yet effective ways to debug is by using Console.WriteLine statements.

Steps to Debug Using Console.WriteLine Statements

  1. Identify the Problem Area: Locate the section of your code where you suspect the problem might be.

  2. Insert Console.WriteLine Statements: Add Console.WriteLine statements before and after the suspected problematic code to print out variable values and flow control.

  3. Check the Results Output of your tests.

  4. Analyze the Output: Look at the values printed on the results console to understand what's going wrong in your code. Adjust your code based on the findings and repeat as necessary.

Here's an example of how to use Console.WriteLine for debugging:

csharp
namespace Challenge
{
    public class Calculator
    {
        public static int CalculateSum(int a, int b)
        {
            Console.WriteLine($"CalculateSum called with arguments: {a}, {b}"); // Log function call
            int sum = a + b;
            Console.WriteLine($"Sum after addition: {sum}"); // Log sum calculation
            return sum;
        }
    }
}