gettype of abstract

Joined
Oct 28, 2007
Messages
3
Reaction score
0
Trying to figure out what would be seen here. I did a sample project, and it seems to be doing what I expected. Let's say I had two classes

-------------------------
class Nut{}

class PeaNut:Nut{}
-------------------------

I then create a method like so:

-------------------------
public void Update(Nut n)
{
Console.WriteLine( n.ToString() );
}
-------------------------

If I pass a Peanut to the Update method, it's type will be aknowledged as a Peanut, and not a Nut, right? Basically if a method argument takes a base class, I can still see the parent class when I access the method argument's base type?

I believe, and correct me if I'm wrong:

The use of an abstract class for a method argument is similar to using an interface, in this capacity.
 
Joined
Oct 28, 2007
Messages
3
Reaction score
0
Any other object folks out there that can chime in on this one? Just need to get my OO head screwed on straight :)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,115
Messages
2,570,698
Members
47,273
Latest member
mikkamuertio

Latest Threads

Top