|
|
| What are queues and stacks? |
Queue is for first-in, first-out (FIFO) structures. Stack is for last-in, first-out (LIFO) structures.
|
| What is ENUM? |
It is used to define constants.
|
| What is nested Classes? |
|
|
Nested Classes are classes within classes.
Public Class ClsNested
Public Class ChildNested
Public Sub ShowMessage()
MessageBox.Show(" Hi this is nested class ")
End Sub
End Class
End Class
|
|
| What is Operator Overloading in .NET? |
It provides a way to define and use operators such as +,-,and / for user-defined classes or structs. It allows us to define / redefine the way operators work with our classes and structs. This allows programmers to make their custom types look and feel like simple types such as int and string.
|
| What is the significance of Finalize method in .NET? |
.NET Garbage collector does almost all clean up activity for your objects. But unmanaged resources(ex: - Windows API created objects, File, Database connection objects, COM objects etc) is outside the scope of .NET framework we have to explicitly clean our resources. For these types of objects .NET framework provides Object. Finalize method which can be overridden and clean up code for unmanaged resources can be put in this section.
|
| How can we suppress a finalize method? |
GC.SuppressFinalize()
|
| What is the use of DISPOSE method? |
Dispose method belongs to IDisposable interface. If any object wants to release its unmanaged code best is to implement IDisposable and override the Dispose method of IDisposable interface. Now once your class has exposed the Dispose method it is the responsibility of the client to call the Dispose method to do the cleanup.
|
| How do i force the Dispose method to be called automatically, as clients can forget to call Dispose method? |
Call the Dispose method in Finalize method and in Dispose method suppress the finalize method using GC.SuppressFinalize.
|
| In what instances you will declare a constructor to be private? |
when we create a private constructor, we can not create object of the class directly from a client. So you will use private constructors when you do not want instances of the class to be created by any external client. Example UTILITY functions in project will have no instance and be used without creating instance, as creating instances of the class would be waste of memory.
|
| Can we have different access modifiers on get/set methods of a property? |
No we can not have differnent modifiers same property. The access modifier on a property applies to both its get and set accessors.
|
| If we write a goto or a return statement in try and catch block will the finally block execute? |
The code in finally always run even if there are statements like goto or a return statements.
|
| What is Indexer? |
An indexer is a member that enables an object to be indexed in the same way as an array.
|
| Can we have static indexer in C#? |
No
|
| Can two catch blocks be executed? |
No, once the proper catch section is executed the control goes finally block. So there will not be any scenarios in which multiple catch blocks will be executed.
|
| What is the difference between System.String and System.StringBuilder classes? |
System.String is immutable; System.StringBuilder can have mutable string where a variety of operations can be performed.
|
|
|
| Prev |