What is the difference between static methods in a Non static class and static methods in a static class?
The only difference is that static methods in a nonstatic class cannot be extension methods.
In other words, this is invalid:
class Test
{
static void getCount(this ICollection<int> collection)
{ return collection.Count; }
}
whereas this is valid:
static class Test
{
static void getCount(this ICollection<int> collection)
{ return collection.Count; }
}
A static class can only contain static members.
A static method ensures that, even if you were to create multiple classB objects, they would only utilize a single, shared SomeMethod function.
Technically, there's no difference, except that ClassA's SomeMethod must be static.
If you have a non-static class containing only static methods, you could create an instance of that class. But you can't use that instance meaningfully. NB: when you don't define a constructor, the compiler adds one for you.
A static class does not have a constructor, so you can't create an instance of it. Also the compiler gives an error when you add an instance method to it (where you meant a static method).
See also docs.