Thanh Thảo
New member
What will be the output of the following C# code snippet?
A. Compile time error
B.
C. 0
D. Run time error
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();
}
}
B.
Code:
Csharp
D. Run time error