Click here to Skip to main content
15,747,059 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
Hi What is the use of class references in c# or any programming languages
myclass m;
m=new myanotherclass();
what is the need of declaring m as object of one class and referring it to another class?
Any help is greatly appreciated.

If you need to make use of data and behaviour of a certain class, you would do it using a class object.
Share this answer
Abhinav S 20-Jul-11 2:47am    
Fairly appropriate. My 5. Don't know why we got downvoted.
Share this answer
Simple - you probably need to either access something (property or method) in the second class (myanotherclass).

In object oriented terms this is known as an Association.
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900