'How to get output from enum using user input? C#
I wrote this code to ask user for inputting one of the values in the enumeration but I don't know how to connect the enumeration values to the user input. Please help.
Thank you!
class Program
{
static void Main(string[] args)
{
System.Console.WriteLine("Hello, please enter the numerical value corresponding to your transportation mode.Car = 10 / Bus = 20 / Bicycle = 5 / Cab = 7.");
int TransportationModeInput = int.Parse(Console.ReadLine());
public enum TransporationMode
{
Car = 10,
Bus = 20,
Bicycle = 5,
Cab = 7
}
int ModeCar = (int)TransporationMode.Car;
int ModeBus = (int)TransporationMode.Bus;
int ModeBicycle = (int)TransporationMode.Bicycle;
int ModeCab = (int)TransporationMode.Cab;
}
}
Solution 1:[1]
I had this problem and fixed it by downgrading my python version to be less than 3.10.
Solution 2:[2]
This problem was informed here, to solve this I edited the httplib2shim package
in C:\Users\USERxx\AppData\Local\Programs\Python\Python310\Lib\site-packages\httplib2shim_init_.py
Changing the line 45:
45 if isinstance(proxy_info, collections.Callable):
for
45 if isinstance(proxy_info, collections.abc.Callable):
and it worked fine
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | jsta |
| Solution 2 |
