How can i create the object without using new [Resolved]

Posted by mareesnectar-12158 under ASP.NET on 2/1/2012 | Points: 10 | Views : 4032 | Status : [Member] | Replies : 8
Hi ....
How can i create the object and how to access the class methods without using new keyword




Responses

Posted by: Pradeepkumar417 on: 2/1/2012 [Member] Starter | Points: 50

Up
0
Down

Resolved
Hi,

You can create an object without new keyword and also you can access all methods with that object by writing code like below

ClassName obj = (ClassName )Activator.CreateInstance(typeof(ClassName ));

Thanks & Regards,
Software Engineer,
Pradeep Kumar

mareesnectar-12158, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Pradeepkumar417 on: 2/1/2012 [Member] Starter | Points: 25

Up
0
Down
Hi,

If we create a class as static then there is no need to create any object. You can directly access all methods and variables with class name only.

Thanks & Regards,
Software Engineer,
Pradeep Kumar

Thanks & Regards,
Software Engineer,
Pradeep Kumar

mareesnectar-12158, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: mareesnectar-12158 on: 2/1/2012 [Member] Starter | Points: 25

Up
0
Down
No static class ....
Normal Class like...
Public Class A


How can i create the object and how to access the class methods without using new keyword

mareesnectar-12158, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Blessyjees on: 2/1/2012 [Member] Bronze | Points: 25

Up
0
Down
Hi,

In the case of normal class you can create object like

A a=new A();

Then you can all methods like a.Add();
You can't create objects without using new keyword. New keyword only used to create object, not use to access class methods.

Blessy Baby
Digitalmesh Softech pvt Ltd
https://blessybaby.wordpress.com/

mareesnectar-12158, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: mareesnectar-12158 on: 2/1/2012 [Member] Starter | Points: 25

Up
0
Down
thanks..
New keyword only used to create object, not use to access class methods
I am also know that ...
if any possible to create object without using new keyword


mareesnectar-12158, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: mareesnectar-12158 on: 2/1/2012 [Member] Starter | Points: 25

Up
0
Down
Any one Reply my question....


mareesnectar-12158, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: mareesnectar-12158 on: 2/2/2012 [Member] Starter | Points: 25

Up
0
Down
Thanks Pradeepkumar417.....


mareesnectar-12158, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Pradeepkumar417 on: 2/2/2012 [Member] Starter | Points: 25

Up
0
Down
Hi,

Thank you.

Thanks & Regards,
Software Engineer,
Pradeep Kumar

mareesnectar-12158, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response