What is generics and have you ever used any generic classes? ( .NET Generic Interview questions)
- By Shiv Prasad Koirala in .Net
- Oct 23rd, 2013
- 7613
- 0
Generics- In simple terms we will define it as General type of programming.
Rather defining something for specific types we will create it in general manner which will work for multiple types.
Let's have an example.
public T Add
return (T)(x+y);
}
.
.
Int x=Add
float y=Add
string s=Add
In technical terms, we will create something (class or function) in such a way that while developing we won't specify the type for which we are creating rather while end developer when actually use it will specify the type.
Examples for generic class:
Yes, I do have used List and Dictionary.
Can you give me the example how you used them?
List
x.add(new Customer()Name="A"});
x.add(new Customer()Name="B"});
Dictionary
y.add(1,"Mr A");
y.add(2,"Mr B");
Below is an awesome C# Generic interview questions with answers video provided by questpond.com
Shiv Prasad Koirala
Visit us @ www.questpond.com or call us at 022-66752917... read more