Click here to Skip to main content
15,913,669 members
Home / Discussions / C#
   

C#

 
AnswerRe: How to avoid from copy of windows in Visualg .Net C# Pin
Robert Rohde9-Dec-06 4:26
Robert Rohde9-Dec-06 4:26 
AnswerRe: How to avoid from copy of windows in Visualg .Net C# Pin
mav.northwind9-Dec-06 4:28
mav.northwind9-Dec-06 4:28 
GeneralRe: How to avoid from copy of windows in Visualg .Net C# Pin
karam chandrabose9-Dec-06 9:08
karam chandrabose9-Dec-06 9:08 
QuestionRe: System.Security.Cryptography.RSAParameters Pin
edchan9-Dec-06 3:49
edchan9-Dec-06 3:49 
QuestionAdd Cotrol Problem Pin
MHASSANF9-Dec-06 3:21
MHASSANF9-Dec-06 3:21 
AnswerRe: Add Cotrol Problem Pin
Robert Rohde9-Dec-06 4:24
Robert Rohde9-Dec-06 4:24 
QuestionRe: Add Cotrol Problem Pin
MHASSANF10-Dec-06 2:55
MHASSANF10-Dec-06 2:55 
QuestionDoubt on C# virtual functions Pin
jithus9-Dec-06 2:30
jithus9-Dec-06 2:30 
The following is a question i faced in an interview...They asked me the ouput of the following code snippet

using System;<br />
<br />
namespace CsharpTestQ<br />
{<br />
	public class ClassA<br />
	{<br />
		public virtual void printStr()<br />
		{<br />
			Console.Write("A");<br />
		}<br />
	}<br />
<br />
	public class ClassB:ClassA<br />
	{<br />
		public override void printStr()<br />
		{<br />
			Console.Write("B");<br />
		}<br />
	}<br />
<br />
	public class ClassC:ClassB<br />
	{<br />
		public virtual void printStr()<br />
		{<br />
			Console.Write("C");<br />
		}<br />
	}<br />
<br />
	public class ClassD:ClassC<br />
	{<br />
		public override void printStr()<br />
		{<br />
			Console.Write("D");<br />
		}<br />
	}<br />
<br />
	class Class1<br />
	{<br />
		<br />
		[STAThread]<br />
		static void Main(string[] args)<br />
		{<br />
<br />
			ClassD d=new ClassD();<br />
			ClassA a=d;<br />
			ClassB b=d;<br />
			ClassC c=d;<br />
<br />
			a.printStr();<br />
			b.printStr();<br />
			c.printStr();<br />
			d.printStr();<br />
<br />
			Console.ReadLine();<br />
			<br />
		}<br />
	}<br />
}

I thought it would be "DDDD" since the object is the same (d) and the vtable in "d" points to the function printStr in ClassD. But when i tried it, the output is "BBDD". Can any one explain what is happening here?
AnswerRe: Doubt on C# virtual functions Pin
Robert Rohde9-Dec-06 2:48
Robert Rohde9-Dec-06 2:48 
GeneralRe: Doubt on C# virtual functions Pin
jithus9-Dec-06 3:35
jithus9-Dec-06 3:35 
GeneralRe: Doubt on C# virtual functions Pin
Robert Rohde9-Dec-06 4:22
Robert Rohde9-Dec-06 4:22 
GeneralRe: Doubt on C# virtual functions Pin
jithus9-Dec-06 6:08
jithus9-Dec-06 6:08 
GeneralRe: Doubt on C# virtual functions Pin
Robert Rohde9-Dec-06 9:16
Robert Rohde9-Dec-06 9:16 
GeneralRe: Doubt on C# virtual functions Pin
jithus10-Dec-06 3:22
jithus10-Dec-06 3:22 
AnswerRe: Doubt on C# virtual functions Pin
karam chandrabose9-Dec-06 9:23
karam chandrabose9-Dec-06 9:23 
Questionserial communication Pin
George_Lucian9-Dec-06 2:01
George_Lucian9-Dec-06 2:01 
AnswerRe: serial communication Pin
Squeaker9-Dec-06 2:58
Squeaker9-Dec-06 2:58 
QuestionI want to backup SQL SERVER 2000 database and zip it using .NET 1.1 . The application must be connect remote system by using windows authentification is there any website to produce the code in .NET 1.1 in any language(c#.net or vb.net) Pin
haneef19-Dec-06 1:33
haneef19-Dec-06 1:33 
QuestionI have problem vith vs2003 editor when press F5 for output c# with asp web application it returns dialog box like Error while trying to run a project: Unable to start debugging on webserver.you do not have permissions to debug the server. verify you Pin
haneef19-Dec-06 1:25
haneef19-Dec-06 1:25 
QuestionAdding Images Pin
Lakshmi Kiran Reddy9-Dec-06 0:59
Lakshmi Kiran Reddy9-Dec-06 0:59 
JokeBILL AND THE PEARLY GATES Pin
Muammar©9-Dec-06 0:57
Muammar©9-Dec-06 0:57 
Questiondesktop access Pin
amgag9-Dec-06 0:30
amgag9-Dec-06 0:30 
QuestionC++ vs. C#: Developing a highly scalable IOCP server Pin
zulat9-Dec-06 0:29
zulat9-Dec-06 0:29 
Questionnightmare updating the data source:( Pin
Muammar©9-Dec-06 0:26
Muammar©9-Dec-06 0:26 
QuestionBind nested object property in DataGridView [modified] Pin
MBursill8-Dec-06 23:27
MBursill8-Dec-06 23:27 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.