© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•3y ago•
6 replies
Grip It and Rip It

❔ Need help selecting a random element out of a list

Hey I'm very new to learning C# and I'm trying to figure out how I would select a random element from a list. I am working with Selenium browser automation and I have a list of potential elements that I want the browser to interact with. I essentially want one element from the list to be selected to be clicked on each time the program runs.

It seems like there should be a more elegant solution than creating an IF, ELSE IF list with 22 entries for the 22 potential variables that could be selected. Is there a way to simply choose an item from a list and append the .click command onto the variable that has been selected?
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

Need help selecting objects in a list
C#CC# / help
17mo ago
❔ Random List of strings
C#CC# / help
4y ago
creating a list of randomly picked out items out of a tuple list.
C#CC# / help
3y ago