When do you use virutal keyword?

Category: OOPS Questions    |    0 views    |    Add a Comment
When we need to override a method of the base class in the sub class, then we give the virtual keyword in the base class method. This makes the method in the base class to be overridable. Methods, properties, and indexers can be virtual, which means that their implementation can be overridden in derived classes.

Share/Save/Bookmark

 

Can you write a class without specifying namespace Which namespace does it belong to by default?

Category: OOPS Questions    |    1 views    |    Add a Comment
Yes, you can, then the class belongs to global namespace which has no name. For commercial products, naturally, you  wouldn’t want global namespace.

Share/Save/Bookmark

 

Can you declare an override method to be static if the original method is non-static?

Category: OOPS Questions    |    2 views    |    Add a Comment
No. The signature of the virtual method must remain the same, only the keyword virtual is changed to keyword override.

Share/Save/Bookmark

 

What is the use of Internal keyword?

Category: OOPS Questions    |    1 views    |    Add a Comment
Internal keyword is one of the access specifier available in .Net framework , that makes a type visible in a  given assembly , for e.g  a single dll can contain multiple modules , essentially a multi file assembly , but it forms a single binary component , so any type with internal keyword will be visible throughout the assembly and can be used in any of the modules .

Share/Save/Bookmark