By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,680 Members | 1,666 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,680 IT Pros & Developers. It's quick & easy.

When to use "new" syntax in object creation

P: n/a
Hi !

A couple of pretty basic questions:

Value types:

As far as I understand, when I create value type without "new" syntax
the object is considered as unutilized. Consequently, I have to
initialize its member variables manually; otherwise I would get an
exception while accessing them.
Does this means that the constructor of the object, which is created
without_new_way wouldn't be called?

Reference types:

Do I always create reference types with "new" syntax or there are some
cases when I create my object without "new" and it still will be
allocated in managed heap?

Thanks.

Jean.
Nov 15 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
> As far as I understand, when I create value type without "new" syntax
the object is considered as unutilized. Consequently, I have to
initialize its member variables manually; otherwise I would get an
exception while accessing them.
Does this means that the constructor of the object, which is created
without_new_way wouldn't be called?
probably so, yes...
anyway you can't define parameterless constructor on struct ...
Do I always create reference types with "new" syntax or there are some
cases when I create my object without "new" and it still will be
allocated in managed heap?

the other case are when someone else call "new" for you ...
Nov 15 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.