Which method is implicitly called when an object is created
When an object is created Constructor is get called first. A default constructor is created automatically if we do not create a constructor inside a class.
Which of the following statement is invalid with regards to constructor
Constructors should have the same name as class name
Constructors have to be public so that class can be instantiated
Constructors can not be overloaded
Constructors can not be static
C# supports two types of constructor, a class constructor (static constructor) and an instance constructor (non-static constructor).
Static constructor is used to initialize static data members as soon as the class is referenced
first time, whereas an instance constructor is used to create an instance of that class with
Since static constructor is a class constructor, they are guaranteed to be called as soon as we refer to that class or by creating an instance of that class.
It is not possible for a delegate to wrap more than 1 methods
False
In some cases you may want to call not just one, but two or more methods through a single delegate. This is known as multicasting. You accomplish multicasting by encapsulating the various methods in delegates, and then you combine the delegates using the Delegate.Combine shared method. The Combine method takes an array of delegates as a parameter and returns a new delegate that represents the combination of all the delegates in the array.
In C# events are actually a special form of delegates
False
Events are signals generated by an object to indicate occurrence of an action, while delegates are type safe function pointers.
An event is a way for a class to signal state change / an interesting action. Delegates are reference types which are used to encapsulate methods with a specific signature.
Events are declared using delegates. Objects which want to take some action on occurrence of the event attach their methods to the event handler, which is a delegate.
Which preprocessor directive are used to mark that contain block of code is to be treated as a single block
#Region and #EndRegion indicates a block of code which can be expanded / collapsed.
How are the attributes specified in C#
They are enclosed with in [].
For performing repeated modification on string which class is preferred?
StringBuilder class is preferred for performing repeated operations on string since its value is mutable. String class represents a text value which is immutable. All operations on string class which appear to be modifying its value actually return the new value.
So for modifying text contents StringBuilder class is preferred.
In order to use stringbuilder in our class we need to refer
We only need to refer System.Text namespace. StringBuilder Class is contained in the System.Text namespace. hence we need to add the following lines in pur code:
using System.Text;
Which of the following is not a member of stringbuilder
Answer is: Dsubstring();
No comments:
Post a Comment