And here's the class that we're going to utilize within this example:
private class SwitchClass
public string WordNum;
public int IntNum;
The way this works revolves around the First/FirstOrDefault method. I've defined 2 arrays in position so that when they get added to the list of SwitchClass (user defined type), they are already created in sync so that each value inside the switchclass list contains proportional "data". Meaning an item in this list will contain for each of the 2 properties, their comparable int and word value within the same item.
Ex: sc item 1 at index of 0 in the list of SwitchClass will contain (based on this for loop) a property of WordNum and IntNum, IntNum containing an integer value and WordNum containing the string value in word of that integer value. So in this case the first item would contain IntNum = 0, and WordNum = "zero" properties.
Now is where FirstOrDefault comes in, we use this to find our Integer value (int/Int32) within the list of SwitchClass (sc) by checking each item property of .IntNum and seeing if it matches our gval int variable. If it does then that is what SwitchClass our num variable now holds, otherwise it will go undefined, and we'll check for that later if you read on.
Now that we hopefully defined the num variable (if not it's okay), we can go ahead and display the WordNum property of that item based on the IntNum property we've searched for by query. If num is not null, that means we've found a match of the IntNum property we've searched for and we can display the WordNum property of that SwitchClass user defined type from the list of SwitchClass we've created. Otherwise if it is null, that means we could not find a value, and therefore based on our if statement logic, we can display "Undefined/Nonexistant" in the textbox when running through this code.
Enjoy, hope you've learned Any questions just ask.