What am I doing wrong here?
return listBoxKeywords.Items[rnd.Next(0, listBoxKeywords.Items.Count)].ToString();
I get the following error:
Error 1 An object reference is required for the non-static field, method, or property
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
This error means that the function returning the random item is static.
Either remove the
statickeyword from the method declaration (and thus make it part of the existing instance), or pass the list box as parameter to the function when calling it.