Wrox Programmer Forums
Go Back   Wrox Programmer Forums > C# and C > C# 2005 > C# 2005
|
C# 2005 For discussion of Visual C# 2005.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the C# 2005 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old October 12th, 2006, 08:10 PM
Registered User
 
Join Date: Sep 2006
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default Application of generics

I've posted recently a question "Generic collection population from database". Let's assume that population has happened whether using reflection or SQL 2005 object type feature.
Now we do have a generic list and I want to a have generic method which emits html table as return string after traversing a list.

       public static string GenerateHtmlTable<T> (List<T> list, string tableName)
        {


            foreach (T t in list)
            {
                System.Diagnostics.Debug.WriteLine(t.ToString());

            }
            System.Diagnostics.Debug.WriteLine("============== =============");
            List<T>.Enumerator row = list.GetEnumerator();
            while (row.MoveNext())
            {
                System.Diagnostics.Debug.WriteLine(t.ToString());
            }
return htmlTable ;
        }

The only solution I was able to come up with is to override ToString to return HTML row or CSV which concatenation of class properties values. Any other ideas ?

TIA
Michael






Similar Threads
Thread Thread Starter Forum Replies Last Post
Generics in 3.0 sikanderwaheed C# 2008 aka C# 3.0 1 May 5th, 2008 08:30 AM
NET Generics FREDYCOREA .NET Framework 3.5 1 February 21st, 2008 10:17 AM
Generics Related error in my code, I think??? rodmcleay Generics 1 August 3rd, 2006 12:02 AM
Problem with generics collections demitry .NET Framework 2.0 4 November 24th, 2005 06:39 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.