vb.net - Export different lists to csv -


at first, have say: new visual basic studio...

my problem is: have different list objects of different types

list<student> s list<teacher> t list<subject> su 

and more.

each list has several attributes, simple strings , int, other complex type. each class (student..), wrote tostring() method.

what need: simple method write every list object csv file (alternatively, write directly mysql table - has wait..). found simple method this:

public void savetofile()     {         using (streamwriter sw = file.createtext("test.csv"))         {             (int = 0; < mylist.count; i++)             {                 sw.writeline(mylist[i].tostring());             }         }     } 

i tried make method generic taking source list parameter, not possible:

public void savetofile(list l) 

because type has declared.

what simplest way? thinking either in objectorientated way (finding "superclass" different list types..) searching simple component job.

any hints? (and sorry if question simple...)

thanks! heiko


Comments

Popular posts from this blog

resizing Telegram inline keyboard -

command line - How can a Python program background itself? -

php - "cURL error 28: Resolving timed out" on Wordpress on Azure App Service on Linux -