What will be the output of the following C# code snippet? [code] public class Generic<T> { Stack<T> stk = new Stack<T>(); public

Thanh Thảo

New member
What will be the output of the following C# code snippet?
Code:
public class Generic<T>
{
    Stack<T> stk = new Stack<T>();
    public void push(T obj)
    {
        stk.Push(obj);
    }
    public T pop()
    {
        T obj = stk.Pop();
        return obj;
    }
}
class Program
{
    static void Main(string[] args)
    {
        Generic<int> g = new Generic<int>();
        g.push("Csharp");
        Console.WriteLine(g.pop());
        Console.ReadLine();
    }
}
A. Compile time error
B.
Code:
 Csharp
C. 0
D. Run time error
 

Tìm kiếm

Back
Top