I am using VS 2008 (C#)... I have created a function in a GlobalClass to use it globally.. This is for opening a dialog box. When I call this function in my method it works but
Do it like this -
static class GlobalClass { public static string OFDbutton() { OpenFileDialog ofd = new OpenFileDialog(); ofd.Filter = "Image files|*.jpg;*.jpeg;*.png;*.gif"; DialogResult dr = ofd.ShowDialog(); return ofd.FileName; } } lable1.text = GlobalClass.OFDbutton();