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 January 28th, 2006, 09:56 PM
Authorized User
 
Join Date: Oct 2004
Posts: 55
Thanks: 0
Thanked 0 Times in 0 Posts
Default How to implement a function return List<T>

I am very interested in C# Generic class specially in List<T>.
Are there any way for me to have a function to return a List<T>
as code segment below. If you know how to do it, please share your idea.

Regards,

Jdang

/***********************************************/
public List<T> ( some parameters..., Type type) {

    switch( type) {

        case Invoice:
        List<Invoice> list = new List<Invoice>;
        ....
        ....
        ....

        return list;

        case Order:

        List<Order> list = new List<Order>;
        ....
             ....
        ....

        return list;
    }
}




 
Old January 29th, 2006, 12:11 PM
Authorized User
 
Join Date: Oct 2004
Posts: 55
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Corrected- function should look likes this:

public List<T> functionName<T>( some parameters..., Type type) {

    switch( type) {

        case Invoice:
        List<Invoice> list = new List<Invoice>;
        ....
        ....
        ....

        return list;

        case Order:

        List<Order> list = new List<Order>;
        ....
        ....
        ....

        return list;
    }
}


 
Old January 30th, 2006, 11:28 AM
Authorized User
 
Join Date: Oct 2004
Posts: 55
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I think the problem is solved.

Thanks






Similar Threads
Thread Thread Starter Forum Replies Last Post
Loading data into List<T> rvincent C# 2005 8 June 14th, 2007 11:27 AM
Tab function + <textarea></textarea> Adam H-W HTML Code Clinic 0 April 24th, 2007 10:36 AM
<style> tags in a <body> vs. <div> bcat BOOK: Beginning CSS: Cascading Style Sheets for Web Design ISBN: 978-0-7645-7642-3 1 March 27th, 2005 08:50 AM
return to value in <SELECT> statement mikeuk Beginning PHP 3 September 25th, 2004 08:46 AM
<marquee><b>About CHAT App. in PHP4</b></marquee> Ramkrishna PHP How-To 1 September 11th, 2004 07:01 AM





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