I am learning C# and am struggling with classes. I have a C# program that uses MySQL methods residing in Form1. Another form, Form2, must share these methods. I added a new class, MyClass, to hold these common methods. I declare them as:
public static string method1() // because all the methods return a string value.
My problem is that in a few cases I have a method that needs to return a ComboBox or a ListBox. I already did this when the method was in Form1, but when I tried to move it to MyClass and set it up as:
public static ComboBox method2()
the ComboBox is not available as a possible return type in the pulldown list (as you type). Neither is ListBox or ArrayList. Array is available but I'm not sure how to use it. The ComboBox and ListBox return types were very convenient to return a list. I could use ArrayList. I haven't tried a string array because of the difficulty in declaring its size before knowing how many items will be returned.
The method is supposed to return a list of items that satisfy the given MySQL query.
Thanks,
-Bob
Will Form1 and Form2 be able to access the methods in MyClass by using:
comboBox1 = MyClass.method(...);
as long as method(...) is declared in MyClass as
public static ComboBox method(...) ?
-Bob