In regards to a static class, if nothing needs instantiating this is a clear reason for a static class. I've not created a class in decades that needed instantiation. Look at extension methods, they need to be in a static class and the extension method must be static.
Simple extension method
internal static class DateOnlyExtensions
{
public static string Formatted(this DateOnly sender) => sender.ToString("MM/dd/yy");
}
A static class where we call DataOperations.CategoriesArray() of CategoriesArray() with a static using statement, similar to say DateTime.Now. or Console.WriteLine, we can use a static using statement so not to type everything out (good for some, bad for others)
namespace MenuConsoleApp.Classes
{
public class DataOperations
{
public static Categories[] CategoriesArray() =>
JsonConvert.DeserializeObject<List<Categories>>(
File.ReadAllText(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "json", "categories.json")))
.ToArray();
}
}
In regards to Singleton, used for dependency injection for services in Startup.cs and Program.cs which make coding easier.
public void ConfigureServices(IServiceCollection services)
{
services.AddRazorPages();
services.AddServerSideBlazor();
services.AddSingleton<RssNews>();
}
That's the tip of the iceberg, best to do research and come to your own conclusions.
See also