1

I need to randomize fixed numbers, for example, 1,3,5,7,10. My output will be only 1,3,5,7 or 10. Please Help me! Thanks! Is there a way to randomize fixed numbers or user inputted numbers?

1 Answer 1

1

Get a random number from 0-4, then select from a dictionary of { 1, 3, 5, 7, 10 }.

int[] select = new int[] { 1, 3, 5, 7, 10 };
var rand = new Random();
int num = select[rand.Next(5)];
Sign up to request clarification or add additional context in comments.

3 Comments

can i use this on string, char? :)
Sorry i am new to this, but how will my code be? What is my code?
I did it! Thanks! I can now finish my work. Thanks dbaseman! :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.