What is purpose & use of NEW keyword behind in C#, except creating object?

Posted by Sivakumar.S under C# on 7/5/2012 | Points: 10 | Views : 3197 | Status : [Member] | Replies : 2
Hi,

What is purpose and use of NEW keyword behind in C#, except creating object ?

Thanks in Advance

siva


Responses

Posted by: Premalatha on: 7/5/2012 [Member] Starter | Points: 25

Up
0
Down
In C#, the new keyword can be used as an operator or as a modifier.

new operator Used to create objects on the heap and invoke constructors.
new modifier Used to hide an inherited member from a base class member.
he new operator is used to create objects and invoke constructors,For
example

Class1 MyClass = new Class1();
It is also used to invoke the default constructor for value types, for example:
int myInt = new int();


Premalatha
Software Engineer

Sivakumar.S, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Akiii on: 7/5/2012 [Member] Bronze | Points: 25

Up
0
Down
Check out this link :-

http://www.dotnetfunda.com/interview/exam647-difference-between-new-and-override-keyword.aspx


Thanks and Regards
Akiii

Sivakumar.S, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response