Generics in C#
http://www.csharpfriends.com
World's Greatest C# Community    
Home Articles C# Forums Books C# Syntax C# Spec C# Jobs free Source Code Advertise About
 

Control Panel

[ Sign In / register ]
Points   
Notes 
My Forums
My Tutorials
My Profile

Resources

Learn
 Articles
 QuickStarts
 C# Spec
 Whitepapers
 Tools
 Class Browser
 C# Code Generator
 Links
 Misc Rss Feeds
 Code Highlight
 411 Directory
 FREE magazines
 freevb.net

Reviews
  ASP.NET Hosting

Source Code
 Get Version 1.0



C# Consulting
AspDotNetStoreFront
Chapter:   C# Types
Current Lesson:
Generics in C#
[Latest Content]
A | B | C | D | E | F | G | H | I | J | K | L | M | N | O | P | Q | R | S | T | U | V | W | X | Y | Z | ALL
[prev. Lesson]  Capturing your Ideas: Review [next Lesson]  Sorting ArrayList Containing User Defined Types
Generics in C#
  by: webmaster

Introduction

Some New features have been added to C# language with version 2.0 of .NET. which are:

  • Generics
  • Iterators
  • Anonymous methods
  • Partial classes

    In this Article I will explain about Generics Feature with some examples.

    Generics

    Generics are used to help make the code in the software components much more reusable. They are a type of data structure that contains code that remains the same. The data type of the parameters can change with each use.The usage within the data structure adapts to the different data type of the passed variables.

    Each time the generic is used, it can be customized for different data types without needing to rewrite any of the internal code. Generics permit classes, structs, interfaces, delegates, and methods to be parameterized by the types of data they store and manipulate.

    We can refer to a class, where we don't force it to be related to any specific Type, but we can still perform work with it in a Type-Safe manner. An example where we could implement Generics is in dealing with collections of items (integers, strings, Orders etc.). We can create a generic collection than can handle any Type in a generic and Type-Safe manner. For example, we can have a single array class to store a list of Users or even a list of Items, and when we actually use it, we will be able to access the items in the collection directly as a list of Users or Items, and not as objects (with boxing/unboxing, casting).


  • 1 2 3  (Page 2) -->


    Build Your Own ASP.NET Website Using C# & VB.NET

    Chapter:  C# Types
    Current Lesson:
    Generics in C#
    [Latest Content]
    A | B | C | D | E | F | G | H | I | J | K | L | M | N | O | P | Q | R | S | T | U | V | W | X | Y | Z | ALL
    [prev. Lesson]  Capturing your Ideas: Review [next Lesson]  Sorting ArrayList Containing User Defined Types


    Today's Top Movers
    vulpes 6800
    MadHatter 2220
    jal 867
    Jeff1203 857
    muster 791

    Yesterday Top Movers
    shakti sin.. 9
    MadHatter 3
    Al_Pennywo.. 2
    C#fanatic 2
    sksandz 1

    Monthly Leaders
    vulpes 6800
    MadHatter 2260
    jal 867
    Jeff1203 857
    muster 791

    Top Members
    mosessaur 18457
    Rincewind 7074
    stanleytan 6995
    vulpes 6800
    Gsuttie 6046

    Great Offers
    .net hosting
    Go To My Pc
    Remote Pc Control
    zonealarm
    spam blocker
    web hosting directory
    ad server   C#
    snadtech GoToMyPc

    Top of Page

    Advertise | About | Link To Us | Privacy Notice Copyright © 2003 - 2005 CSharpFriends.com  All Rights Reserved  Visual C# Developer Center