One thing to keep in mind is that the area will play a role in this. If you defined S1 as a class variable, then you checked it inside a function that the compiler would not stop, and the code would work fine. The reason is that the variable is initialized when the class is instantiated.
Moving inside the method, and there is a good chance that you forgot something when testing a variable before initializing it.
Another caveat I see is that the default string is? (And even more importantly, this is in the specification, which will not change? Keep in mind that the empty string does not match the zero string. There is a way around this, although you can check with string.IsNullOrEmpty (S1) instead.
Kirk Oct 9 2018-10-09 21:51
source share