gs gs108 Delegates, Generics and LINQ - Generic Methods - Quiz No.1
gs gs108 CSharp Quiz
This quiz belongs to book/course code gs gs108 CSharp of gs organization. We have 110 quizzes available related to the book/course CSharp. This quiz has a total of 10 multiple choice questions (MCQs) to prepare and belongs to topic Delegates, Generics and LINQ. NVAEducation wants its users to help them learn in an easy way. For that purpose, you are free to prepare online MCQs and quizzes.
NVAEducation also facilitates users to contribute in online competitions with other students to make a challenging situation to learn in a creative way. You can create one to one, and group competition on an topic of a book/course code. Also on NVAEducation you can get certifications by passing the online quiz test.
public class MyContainer<T> where T: class, IComparable { /* insert code here */ }
public class Csharp { public void subject<S>(S arg) { Console.WriteLine(arg); } } class Program { static Void Main(string[] args) { Csharp c = new Csharp(); c.subject("hi"); c.subject(20); } }
public class Generic<T> { public T Field; } class Program { static void Main(string[] args) { Generic<String> g = new Generic<String>(); g.Field = "Hi"; Console.WriteLine(g.Field); } }
public class Generic<T> { public T Field; } class Program { static void Main(string[] args) { Generic<int> g2 = new Generic<int>(); Generic<int> g3 = new Generic<int>(); g2.Field = 8; g3.Field = 4; if (g2.Field % g3.Field == 0) { Console.WriteLine("A"); } else Console.WriteLine("Prints nothing:"); Console.ReadLine(); } }
public class MyContainer<T> where T: IComparable { /* insert code here */ }
public class Generic<T> { public T Field; public void testSub() { T i = Field + 1; } } class Program { static void Main(string[] args) { Generic<int>g = new Generic<int>(); g.testSub(); } }
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(); } }