Interview Question in LINQ


 

Interview Question :: How do I do this in cSharp

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication30
{
class Program
{
static void Main(string[] args)
{
string userIn = "0";

while (userIn != "e")
{
Console.WriteLine("Please Select an Option");
Console.WriteLine();
Console.WriteLine("Enter n to display name and student number");
Console.WriteLine("Enter t to enter the times tables.");
Console.WriteLine("Enter e to exit");
userIn = Console.ReadLine();








if (userIn == "n")
NameMeth();


else
if (userIn == "t")

TimeMeth();




else
if (userIn != "e")

Console.WriteLine ("Error {0} is Invalid",userIn);













}


}












public static void NameMeth()
{
Console.WriteLine("Name:Thomas Anderson \nStudent#: 300495656");
}


public static void TimeMeth()
{
int x;
int y;
int total;
string userIn = "0";

Console.WriteLine("Please Enter an Integer");
userIn = Console.ReadLine();
y = Convert.ToInt32(userIn);




for (x = 1; x <= 12; x++)
{
total = y * x;
Console.WriteLine("{0} times {1} is {2}", y, x, total);







}

}


I want to ask the user for the interger in the if statement and then pass it off to the method name TimeMeth but i keep getting an error with the last else. How do I do this?







by ksk