Jump to content

c# method - *ex delphi developer!*


Guest Will

Recommended Posts

scenario:

I want to make a method, i can pass a filename and an object (combobox or listbox) returning the number of items added as an integer.

. - the gubbins of making the listbox fill with the contents of the file is fine..

Problem:

How do i specify the list/combobox in the method?

ie destination is comboBox1 ???

private int getandfillfilecontents(string filename, object??? destination)

 {

 //here i open filename read contents line by line

into destination :

destination.Items.Add(nextline);

 }[/code]

Hope this makes sense, i'm sure it's simple if you know the syntax!

Link to comment
Share on other sites

Guest MrMagoo

now i am not a .net fan and don't do a lot in c#

that said, i think you can do this:

private int getandfillfilecontents(string filename, System.Windows.Forms.ComboBox destination) 


      { 


      //here i open filename read contents line by line 


into destination : 


destination.Items.Add(nextline); 


      }

Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.