- Home
- .NET coding challenges
- Initialising a C# static class won't compile
Initialising a C# static class won't compile
Static classes work in the same way as classes apart from one fundamental difference. They cannot be initalised.
Essentially, you are not able to use the new
operator on a static class.
Learn more about static classes and class members from the Microsoft website.
We have this static CategoryHelper
class.
public static class CategoryHelper
{
public static List<int> GetAllCategoryIds()
{
return new List<int>();
}
}
If we wanted to call the GetAllCategoryIds
method, how would we do it?
Give us your anonymous feedback regarding this page, or any other areas of the website.
Related challenges
Removing the last character from a string
This coding challenge involves writing a C# method that will removing the last character from a string and returning the value.
Contains online code editor
Write a C# function to convert MPH to KPH
Take our coding challenge to write a C# function with the necessary parameters that converts miles-per-hour (MPH) to kilometres-per-hour (KPH) and vice-versa.
Contains online code editor