We have seen how to use is operator before type casting. Another way to check whether type casting was successful or not, is as keyword. If the type casting was successful, reference variable point to that object in memory. If the type casting was failed, then reference variable contains a null value. So before execution
From inheritance, we know that a base class always contains most of the common features and we also know a base class reference variable can point to the derived class object, but vice versa is not possible because a derived class is an extended version of a base class and it contains more functionally than
If you want to prevent any class to be used as a base class in inheritance chain, you can mark that class sealed using sealed keyword. Sealed class is normally a last class in the inheritance chain. A sealed class can inherit from other class or interface, but other classes cannot inherit from it. Apart
We have seen how classes like StreamReader and StreamWriter work. Both the classes contain a method called Close(), which we must call after finishing our job to release any system related resources associated with them. In both classes, there is one another method called Dispose(). This method completely destroys the object from the memory. When
StreamWriter class is used for writing directly to the text files. Like StreamReader class, it also resides in System.IO namespace and you must also include the same on top of your code file. While creating an instance of StreamWriter class, you can directly pass the path of the text file to the constructor. If the