TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
C# Corner
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Generics in C#
Karthikeyan Anbarasan
Mar 31, 2011
3.4
k
0
0
facebook
twitter
linkedIn
Reddit
WhatsApp
Email
Bookmark
How to use generics in C#.
This blog shows on how to use Generics in C#.
public virtual int Add(object value);
public virtual object this[int index] {get; set;}
System.ollections.ArrayList list = new System.Collections.ArrayList();
list.Add("a string");
list.Add(45); //no exception thrown
list.Add(new System.Collections.ArrayList()); //no exception
foreach(string s in list) { //exception will be thrown!
System.Console.WriteLine(s);
}
Generics in C#
Next Recommended Reading
Generic vs Non Generic collections