As a novice in C#, I'm trying to read each row from a datable. Then depending of the value from a special column, I will use that value into a switch.
Here the portion of the code that is bothering me :
foreach(DataRow row in dtTableList.Rows)
{
string selection = (from DataRow line in dtTableList.Rows select (string)line["Name"]);
switch(selection)
{
//The switch case statement
}
The line with "string selection" is apparently wrong, I get as an error message :
"Cannot implicitly convert type 'System.Collections.Generic.IEnumerable' to 'string'"
I tried replacing string selection
by var selection
but then I can't use it in my switch.
Do any of you know what could possibly be the cause of my error and how to solve it ?
For information, I tried to apply the code from another post on StackOverflow.