why use new in c#
Hi
Why we use (new) in every object in c# for example(SQL command cmd=new sqlcommand())?
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Dharmraj ThakurPosted Jun 2, 2017, 4:23 AM
It is used to create instances of anonymous types.
The
newoperator is also used to invoke the default constructor for value types.The
newoperator cannot be overloaded.If the
newoperator fails to allocate memory, it throws the exception, OutOfMemoryException.