Results 1 to 2 of 2

Thread: Get out put without taking argument

  1. #1
    Junior Member
    Join Date
    Aug 2007
    Answers
    16

    Get out put without taking argument

    Doubt in a program using static methods and static classes
    In the below program in the static method I am taking a argument string s.

    Without taking a argument, how can I get the same output ie “hi”,
    but I should use static methods and static classes.

    // In general declaration
    static class test
    {
    public static void show(String s)
    {
    MessageBox.Show(s);
    }
    }

    private void button1_Click(object sender, EventArgs e)
    {
    test.show("HI");
    // test t = new test();
    }


  2. #2
    Junior Member
    Join Date
    Dec 2007
    Answers
    3

    Re: Get out put without taking argument

    // In general declaration
    static class test
    {
    public static s as string; // Declare static variable . so that u can use in any one class by using (test.s)
    public static void show()
    {
    MessageBox.Show(s);
    }
    }

    private void button1_Click(object sender, EventArgs e)
    {
    s="HI"; // put the data into static variable s . If ur using in the same class then u can use s directlry. Other wise u have to use s after class name(eg. test.s="HI"
    }


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
About us
Applying for a job can be a stressful and frustrating experience, especially for someone who has never done it before. Considering that you are competing for the position with a at least a dozen other applicants, it is imperative that you thoroughly prepare for the job interview, in order to stand a good chance of getting hired. That's where GeekInterview can help.
Interact