C# Programming - Collection Classes - Discussion

Discussion Forum : Collection Classes - General Questions (Q.No. 6)
Which of the following statements are correct about the C#.NET code snippet given below?
Stack st = new Stack();
Dissimilar elements like "hello", 8.2, 5 cannot be stored in the same Stack collection.
Boolean values can never be stored in Stack collection.
In the fourth call to Push(), we should write "b" in place of 'b'.
To store dissimilar elements in a Stack collection, a method PushAnyType() should be used in place of Push().
This is a perfectly workable code.
Answer: Option
No answer description is available. Let's discuss.
4 comments Page 1 of 1.

Sangeetha.t said:   5 years ago
Implement collection namespace. So you can see a stack option. In which it accepts all data type because it requires only an object not a specific datatype.

Sridhar said:   6 years ago
Only value data type can stored stack. Then how option E is right?

Farhat said:   1 decade ago
At the very first line we can't declare stack like that we have to define the generic type of stack here.

Syed said:   1 decade ago
Since Push method take parameter as object. Hence any data type can be stored in the Stack object.

Post your comments here:

Your comments will be displayed after verification.