Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why have all static methods/variables in a non-static class?

Tags:

c#

.net

oop

I have come across a class which is non-static, but all the methods and variables are static. Eg:

public class Class1 {

    private static string String1 = "one";
    private static string String2 = "two";

    public static void PrintStrings(string str1, string str2)
    {
       ...

All the variables are static across all instances, so there is no point having separate instances of the class.

Is there any reason to create a class such as this?

like image 248
CJ7 Avatar asked Apr 28 '10 11:04

CJ7


1 Answers

Was the class written back in the .NET 1.x days? Static classes didn't appear until C# 2.0.

like image 171
Matt Hamilton Avatar answered Oct 21 '22 13:10

Matt Hamilton