When should I use static class and when Interface?
I have a class that deals with string manipulations. Should I make it static class or should I make it implement an interface and reference the interface?
When should I use static class and when Interface?
I have a class that deals with string manipulations. Should I make it static class or should I make it implement an interface and reference the interface?
A static class is a useful place to put a bunch of utility functions (string manipulations would be a good fit here). You might also consider making your string manipulations methods into extension methods.
You might be interested in When to Use Static Classes in C#, which covers some of the pros and cons of using static classes and methods. My general take is that for simple cases it's "okay", though for a more mature architecture you might look into more advanced designs (that doesn't necessarily mean interfaces.)
An interface is useful if you want to have multiple implementations of some functionality. Interfaces are often used for dependency injection because it allows you to swap in different kind of objects when testing. They're kind of apples and oranges.
You're asking "should I use X or Y" . The answer is X (static classes) can sometimes be appropriate for this situation, Y (interfaces) is not appropriate for this situation, and you forgot to consider W and Z (alternatives mentioned in the other SO question I linked to).
If it deals with non-specific string manipulation, you might think of using extension methods (for string). Than you can use it anywhere with methods like it belongs to the string class.
With non-specific string manipulation, I mean it can be for generic purposes, like e.g. reversing it, uppercasing (these functions already exist, but maybe your string functions are in this class). I mean methods which are not part of your domain.
Extension methods are easier to use. Instead of saying: SomeStaticClassName.YourFunction(yourString) you can write: yourString.YourFunction().
Generally, static classes should only be used when you are sure you need one. Mostly it is a design problem if you need it, but there are exceptions, like utility classes: classes that are like helper classes and do not contain any state (thus need no instance).
Interfaces are from a completely other category, with interfaces you can define that classes should have some behavior (and have it implemented specifically for that class).
If the outcome of the manipulation is deterministic then I would consider making it static. Otherwise, I'd hide it behind an interface as I would probably want to provide a fake for testing.