-4

Below is the sample code

public class class1
    {
        public static void emp(string name)
        {
        .....
        value = (value that is returned)
        }
}

public class class2
    {
 public static void studen(string division)
        {
        ...
        }
        }

This is how i want to use. class2.studen(value);

Here i need to pass the value that is returned from class1 to the string division of class2. Any help would be appreciated.

Here function emp and studen are in different class files.

stackdoubt
  • 11
  • 5

1 Answers1

1

As hatchet mentioned, you're not getting a result from class1. There's a lot of info missing from your post but based on what I think you're trying to do, try like this:

public class class1
{
    public static string value { get; set; } // use the proper type here if it's not a string

    public static void emp(string name)
    {
        .....
        this.value = (value that is returned)
    }
}

public class class2
{
    public static void studen(string division)
    {
        class1.emp("Hello");
        string class2Var = class1.value; // class2Var will now be "Hello"
    }
}
DSN
  • 360
  • 2
  • 9