Dragnorian
New member
- Joined
- Aug 14, 2017
- Messages
- 3
- Programming Experience
- 1-3
Hello! I am very new to C# and new to these forums so I apologize if this is the wrong area to post this. The reason I come to the forums is simply: I have no idea how to word this properly into Google. Anyways, I have created a separate class and created a sub method in that class that will take care of creating random integers. Here is the code for this part:
Now, when I am in my main form, I can call up the RandomEventModifier variable but I am unable to get the correct value. The correct value of the variable is 10 as stated in the code at the near bottom. In the main form, I get a returned value of 0. Here is the code from where I call it:
Any suggestions?
C#:
class search
{
public static Int16 RandomEventModifier;
public static string RandomEventName;
//###########################################
public static void RandomEvents()
{
Random eventmod = new Random();
RandomEventModifier = 10;
}
}
}
C#:
private void btnSearch_Click(object sender, EventArgs e)
{
MessageBox.Show(search.RandomEventModifier.ToString());
}