English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

pls tell me in detail about stack class,polimorphysm

2006-12-21 18:11:37 · 2 answers · asked by shantilal y 1 in Computers & Internet Programming & Design

2 answers

In .NET (VB.NET or c# or any other language), a Stack is a special kind of array. It is closely related to the actual memory stack that lower-level programming languages access. It is special because while most arrays can be read at any point, a stack is exactly what it sounds like - a stack of objects.

A normally array looks like this:

A
B
C

A is in position 0, B is in position 1, and C is in position 2. You can retrieve the second item in the array by saying Array(1). That will get you B.

A stack is different. Imagine a stack of paper. The top sheet has A, the second B, and the third C. If you want to find the piece of paper with C, you have to start by looking at the top sheet, then removing it and looking at the next one under it, until you find the one you want.

Stacks are extremely fast (much faster than arrays), but obviously limited to very specific situations. If you have a situation where you need to read through a very large collection of objects sequentially, you should use a stack.

----

Polymorphism is an OOP (object-oriented programming) concept. It means that a single definition can be used with different types of data. For example you might want to write a function NotifyUser() that you will use in several different areas. Sometimes, you will want to pass a userID - a unique number that identifies the user - so you would write the function as

Function NotifyUser(ByVal UserID as Integer)

But in other places, you might not have the UserID, but you have the username - a string. So you write another copy of the function with the same name:

Function NotifyUser(ByVal UserName as String)

Now, you can call NotifyUser() with either an integer or a string.

There's alot more to polymorphism than that, but it's a very simple example also known as "overloading". See the Wikipedia reference for more info.

2006-12-21 18:24:14 · answer #1 · answered by Rex M 6 · 0 0

Here you go
http://www.vbdotnetheaven.com/Sections/Tutorials.asp
///

2006-12-22 02:13:54 · answer #2 · answered by jan 7 · 0 0

fedest.com, questions and answers