Click here to Skip to main content
15,891,621 members
Please Sign up or sign in to vote.
1.00/5 (6 votes)
See more:
What is the output of this program?

C#
classA a = new classA() { data = 5 };

classA b = a;

b.data = 10;

Console.WriteLine(a.data);
Posted
Updated 17-Jul-13 1:09am
v2
Comments
[no name] 17-Jul-13 7:28am    
Are you currently trying to do your homework? Try to take a test? Being interviewed?

C#
10


(I do have a compiler).
 
Share this answer
 
v2
Comments
Espen Harlinn 17-Jul-13 8:34am    
and a brain ;)
CPallini 17-Jul-13 8:43am    
Please, let my wife know it :-)
By the way, thank you.
Maciej Los 17-Jul-13 9:00am    
Where to send information to your wife? ;)
+5!
CPallini 17-Jul-13 9:10am    
Thank you. :-)
Hi bado,

May I ask a counter question: I can guess what this will print without running it, even if it's not a "Program" just a snippet of code - will this help you in any way? On the other hand this code has no unique meaning (I'd assume classA is a reference type, but who knows maybe you did something like that:

struct classA { }

Assuming you are a studend/learner I'd say try to understand what this example is showing you (pointers, references, alias). Any specific understanding problems? -> Ask a specific question....

Kind regards

Johannes
 
Share this answer
 
Run it and find out! we are not here to do your testing for you!
 
Share this answer
 
Comments
bado2015 17-Jul-13 7:12am    
i just make it must be create ClassA Then the Que i have met don't tell me what inside that ClassA

or ClassA have a namespace to define it ?
Pheonyx 17-Jul-13 7:15am    
It tells you all you need to create a class that matches ClassA for your purposes. Define ClassA then write the main body of the program.
Maciej Los 17-Jul-13 9:01am    
Yes, yes and one more time yes!
+5!

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