Click here to Skip to main content
15,902,870 members
Home / Discussions / C#
   

C#

 
QuestionBest XMPP/Jabber Library? Pin
Mohammad Tarik21-Feb-10 20:24
Mohammad Tarik21-Feb-10 20:24 
AnswerRe: Best XMPP/Jabber Library? Pin
Mohammad Tarik22-Feb-10 19:22
Mohammad Tarik22-Feb-10 19:22 
AnswerRe: Best XMPP/Jabber Library? Pin
Dutchboy00348-Mar-10 1:50
Dutchboy00348-Mar-10 1:50 
GeneralRe: Best XMPP/Jabber Library? Pin
Mohammad Tarik8-Mar-10 9:51
Mohammad Tarik8-Mar-10 9:51 
QuestionDetect theme? Pin
o m n i21-Feb-10 19:16
o m n i21-Feb-10 19:16 
AnswerRe: Detect theme? Pin
Gopal.S21-Feb-10 20:03
Gopal.S21-Feb-10 20:03 
QuestionGenerics Pin
Satish Pai21-Feb-10 18:50
Satish Pai21-Feb-10 18:50 
AnswerRe: Generics [modified] Pin
Dan Mos21-Feb-10 19:01
Dan Mos21-Feb-10 19:01 
Hy,

This MSDN usage definition on Generic Types is the best I think:

  • You can use generic types/classes to maximize code reuse, type safety, and performance.
  • The most common use of generics is to create collection classes.


List<T> is possibly one of the best example:

It has generic type in that you can create a List of ints, strings... your own defined types.

It has type safety => you can not add "Dan" to a list if ints

It has performance => no need to cast from object to yourType

[EDIT]Here's a better usage of generics for your example:

public class Student
{
  private string name = "satish";
  private Int16 RollNo = 12;

  public void displayStudent()
  {
    Console.WriteLine(name);
    Console.WriteLine(RollNo);
    Console.ReadLine();
  }
}

class Program
{
  static void Main(string[] args)
  {
    List<Student> students = new List<Student>();
    students.Add(new Student());
    foreach(var std in students){
      std.displayStudents();
    }
  }
}

[/EDIT]
modified on Monday, February 22, 2010 1:12 AM

GeneralRe: Generics Pin
Satish Pai21-Feb-10 19:09
Satish Pai21-Feb-10 19:09 
GeneralRe: Generics Pin
Dan Mos21-Feb-10 19:11
Dan Mos21-Feb-10 19:11 
GeneralRe: Generics Pin
Satish Pai21-Feb-10 19:22
Satish Pai21-Feb-10 19:22 
QuestionSingle instantiation of Class Pin
i gr821-Feb-10 18:18
i gr821-Feb-10 18:18 
AnswerRe: Single instantiation of Class Pin
Dan Mos21-Feb-10 18:34
Dan Mos21-Feb-10 18:34 
AnswerRe: Single instantiation of Class Pin
PIEBALDconsult22-Feb-10 8:51
mvePIEBALDconsult22-Feb-10 8:51 
QuestionSocket Library Pin
rexbloom21-Feb-10 18:17
professionalrexbloom21-Feb-10 18:17 
Questionknow program installed in computer offline Pin
gpsushil21-Feb-10 18:14
gpsushil21-Feb-10 18:14 
QuestionMake Application Uninstall Available In Programs List Using Windows Installer Pin
BlitzPackage21-Feb-10 13:11
BlitzPackage21-Feb-10 13:11 
AnswerRe: Make Application Uninstall Available In Programs List Using Windows Installer Pin
Anubhava Dimri21-Feb-10 23:24
Anubhava Dimri21-Feb-10 23:24 
QuestionCant see TextBox1 in codeView [modified] Pin
It_tech21-Feb-10 7:19
It_tech21-Feb-10 7:19 
AnswerRe: Cant see TextBox1 in codeView Pin
Pete O'Hanlon21-Feb-10 9:22
mvePete O'Hanlon21-Feb-10 9:22 
QuestionQuestion on lifetime of context existance Pin
Michael J. Eber21-Feb-10 6:53
Michael J. Eber21-Feb-10 6:53 
AnswerRe: Question on lifetime of context existance Pin
Not Active21-Feb-10 7:14
mentorNot Active21-Feb-10 7:14 
GeneralRe: Question on lifetime of context existance Pin
Michael J. Eber21-Feb-10 8:47
Michael J. Eber21-Feb-10 8:47 
GeneralRe: Question on lifetime of context existance Pin
Not Active21-Feb-10 9:47
mentorNot Active21-Feb-10 9:47 
GeneralRe: Question on lifetime of context existance Pin
Michael J. Eber21-Feb-10 18:09
Michael J. Eber21-Feb-10 18:09 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.