RE: How to I Start with C# Generics?
From: Lingeshwaran Palaniappan (lipalani_at_online.microsoft.com)
Date: 08/18/04
- Next message: Kevin C: "Re: Data Access Interfaces, Mapping and Domin model"
- Previous message: Nicholas Paldino [.NET/C# MVP]: "Re: Multi-threaded p/invoke"
- Messages sorted by: [ date ] [ thread ]
Date: Wed, 18 Aug 2004 20:54:19 GMT
Hi,
as suggested the logical thing to do would be to try yourself.
You might find this link useful:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnvs05/html
/csharp_generics.asp
--------------------
>From: anonieko@hotmail.com (Anonieko Ramos)
>Newsgroups: microsoft.public.dotnet.languages.csharp
>Subject: How to I Start with C# Generics?
>Date: 24 Jul 2004 13:23:28 -0700
>Organization: http://groups.google.com
>Lines: 77
>Message-ID: <562cba23.0407241223.67f5066d@posting.google.com>
>NNTP-Posting-Host: 68.161.38.231
>Content-Type: text/plain; charset=ISO-8859-1
>Content-Transfer-Encoding: 8bit
>X-Trace: posting.google.com 1090700609 1116 127.0.0.1 (24 Jul 2004
20:23:29 GMT)
>X-Complaints-To: groups-abuse@google.com
>NNTP-Posting-Date: Sat, 24 Jul 2004 20:23:29 +0000 (UTC)
>Path:
cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!newsfeed00.sul.t-online.de!t-onlin
e.de!tiscali!newsfeed1.ip.tiscali.net!proxad.net!postnews2.google.com!not-fo
r-mail
>Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.languages.csharp:261009
>X-Tomcat-NG: microsoft.public.dotnet.languages.csharp
>
>The logical thing to do is to try it yourself.
>
>>
>>
>>
>>
>
>See this example:
>-----------------------------------------------------------
>
>using System;
>using System.Collections.Generic;
>
>namespace Tests
>{
>
> public class Employee
> {
> int id;
> string name;
>
> public Employee(int anId, string aName)
> {
> this.id = anId;
> this.name = aName;
> }
>
> public int Id
> {
> get { return this.id; }
> }
>
> public string Name
> {
> get { return this.name; }
>
> set { this.name = value; }
> }
> }
>
>}
>
>
>
>namespace Tests
>{
>
> public class GenericReferenceArrayListTest {
>
> static void Main()
> {
> DateTime start = DateTime.Now;
>
> List<Employee> employees = new List<Employee>();
>
> Employee emp = new Employee(101, "Smith, Joan");
>
>
> for (int i = 0; i < 1000000; i++)
> {
> employees.Add(emp);
> }
>
> foreach (Employee e in employees)
> {
> Employee currentEmployee = e;
> }
>
> DateTime finish = DateTime.Now;
>
> System.Console.WriteLine(String.Format("Elapsed time: {0}",
>finish.Subtract(start)));
> }
>
> }
>
>}
>
-- Lingeshwaran Palaniappan, Developer Division This posting is provided "AS IS" with no warranties, and confers no rights. Note: For the benefit of the community-at-large, all responses to this message are best directed to the newsgroup/thread from which they originated.
- Next message: Kevin C: "Re: Data Access Interfaces, Mapping and Domin model"
- Previous message: Nicholas Paldino [.NET/C# MVP]: "Re: Multi-threaded p/invoke"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|