Wrox Programmer Forums
Go Back   Wrox Programmer Forums > C# and C > C# 1.0 > C#
| Search | Today's Posts | Mark Forums Read
C# Programming questions specific to the Microsoft C# language. See also the forum Beginning Visual C# to discuss that specific Wrox book and code.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the C# section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old August 26th, 2008, 05:37 AM
Authorized User
 
Join Date: Apr 2007
Location: Delhi, Delhi, India.
Posts: 61
Thanks: 0
Thanked 0 Times in 0 Posts
Default Difference between Instance and Object in #

Halo,

Q. No- 1 What is the difference between Instance and Object in C#
and
Q. No- 2
class A
{
public virtual void get()
{
Console.WriteLine("Hello");
}
}
class B:A
{
public override void get()
{
Console.WriteLine("Fine");
}
}



Ist Method
A e = new B();
e.get();

IInd Method
B e = new B();
e.get();

Difference between in Ist Method and IInd Method of intializing the object of the the Class A

 
Old August 26th, 2008, 05:41 AM
Friend of Wrox
 
Join Date: Mar 2007
Location: Hampshire, United Kingdom.
Posts: 432
Thanks: 0
Thanked 1 Time in 1 Post
Default

Answer: Do your own homework.

Rob
http://cantgrokwontgrok.blogspot.com
 
Old August 26th, 2008, 05:49 AM
samjudson's Avatar
Friend of Wrox
Points: 8,687, Level: 40
Points: 8,687, Level: 40 Points: 8,687, Level: 40 Points: 8,687, Level: 40
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Aug 2007
Location: Newcastle, , United Kingdom.
Posts: 2,128
Thanks: 1
Thanked 189 Times in 188 Posts
Default

Te-he :)

/- Sam Judson : Wrox Technical Editor -/
 
Old August 26th, 2008, 07:15 AM
Authorized User
 
Join Date: Apr 2007
Location: Delhi, Delhi, India.
Posts: 61
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I'm not getting the right answer. If you can suggest me the way tht's very better.....................

 
Old August 26th, 2008, 07:26 AM
Friend of Wrox
 
Join Date: Mar 2007
Location: Hampshire, United Kingdom.
Posts: 432
Thanks: 0
Thanked 1 Time in 1 Post
Default

Well, what ever course you are doing MUST have covered object instantiation, inheritance and the like..

And even if it hasn't, type the code, what does the code tell you?

Rob
http://cantgrokwontgrok.blogspot.com
 
Old August 26th, 2008, 08:15 AM
Authorized User
 
Join Date: Apr 2007
Location: Delhi, Delhi, India.
Posts: 61
Thanks: 0
Thanked 0 Times in 0 Posts
Default

<b>(Differnce between Instance and Object)</b> I knw this is very basic question. Plz visit this link http://www.codeproject.com/script/Fo...49&msg=2694434<b>.NET- India</b> is my name(in the community) then u can understand why i m so confused it has taken a long discussion but still not very clear and understandable......

 
Old August 26th, 2008, 08:26 AM
samjudson's Avatar
Friend of Wrox
Points: 8,687, Level: 40
Points: 8,687, Level: 40 Points: 8,687, Level: 40 Points: 8,687, Level: 40
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Aug 2007
Location: Newcastle, , United Kingdom.
Posts: 2,128
Thanks: 1
Thanked 189 Times in 188 Posts
Default

You don't need to ponder this one very long - all you need to do is type the code up and compile it - it will give you the answer in front of you.

/- Sam Judson : Wrox Technical Editor -/
 
Old August 26th, 2008, 08:42 AM
Authorized User
 
Join Date: Apr 2007
Location: Delhi, Delhi, India.
Posts: 61
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Yes i got my second question's answer by implementing a simple question

the question was Diff between
A e=new B();
e.get();

B e=new B();
e.get();

But still a bit confused about "diff between instance and object"

 
Old August 26th, 2008, 08:50 AM
Friend of Wrox
 
Join Date: Mar 2007
Location: Hampshire, United Kingdom.
Posts: 432
Thanks: 0
Thanked 1 Time in 1 Post
Default

So what are you saying? You don't know what the words "object" and "instance" mean?!

Rob
http://cantgrokwontgrok.blogspot.com
 
Old August 26th, 2008, 09:22 AM
Authorized User
 
Join Date: Nov 2006
Location: Valparaiso, IN, USA.
Posts: 93
Thanks: 0
Thanked 1 Time in 1 Post
Default

I don't like these kinds of ambiguities, especially in software development. In object oriented programming, an object is an instance of a class period! The object doesn't exist until the class is instantiated and memory has been allocated (part of the instantiation process).


What you don't know can hurt you!




Similar Threads
Thread Thread Starter Forum Replies Last Post
Object Reference not set to an instance of object srinivas_chakka ASP.NET 1.0 and 1.1 Professional 0 February 8th, 2006 11:56 AM
Object Reference is Not Set to an Instance of an O blackinwhite General .NET 4 February 1st, 2005 05:42 AM
Object reference not set to an instance... steelman BOOK: ASP.NET Website Programming Problem-Design-Solution 6 May 7th, 2004 02:03 AM
How do i create an instance of an active x object RDosch Classic ASP Basics 1 July 9th, 2003 06:11 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.