- namespace AccountOrganizer
- {
- public class SetName
- {
- string[] MaleNames =
- { "Jack",
- "Micheal",
- "Mike",
- "Jordan",
- "James",
- "William",
- "David",
- "Richard",
- "Charles",
- "Daniel",
- "Kevin",
- "Brian",
- "George",
- "Edward",
- "Ronald",
- "Jason",
- "Jeffrey",
- };
- List<string> MaleNameList = new List<string>(MaleNames);
- Random r = new Random();
- int Random = r.Next(0, MaleNameList.Count());
- string sethename = MaleNameList[Random];
- }
- }
Getting a error while create a simple class
am i not allowed to create a list and a random object in a class?

Sachin SinghRank #66 · 26.2K reputationPosted Dec 21, 2020, 12:09 AM EST
Sachin SinghRank #66 · 26.2K reputationPosted Dec 20, 2020, 11:45 PM EST
osyris zosarRank #6,574 · 262 reputationPosted Dec 21, 2020, 12:01 AM EST
and why do i need to declare a method?
Amit GuptaRank #190 · 12.8K reputationPosted Dec 21, 2020, 1:06 AM EST
Amit GuptaRank #190 · 12.8K reputationPosted Dec 21, 2020, 1:17 AM EST