You've declared a string called "Type" (just before the switch statement) which you are assigning one of several values within the switch statement, but is then never used.
I assume there is a typo in the above (there are a few in fact), since your return statement is within the switch statement after the default case. I would be surprised if it even compiles like that! You need an extra closing brace before the return.
Not sure how to answer the second part of your question, since it's not clear where "id" is supposed to come from, but I suspect you meant to name the variable that you've called "Type", "id" instead. This would fix both problems. (Not a good idea having a variable called "Type" anyway, since Type is a property of all objects).
If this really is a method in your code, I also suggest you check out Microsoft's coding standards naming conventions. E.g. methods should be Pascal case, not camel case, and I would recommend not beginning with the word "switch".
Finally, since string is immutable, your code would be more efficient if you use StringBuilder, or string.Format, to avoid reallocating memory each time you append to it.
Suggested correction:
public string GetCourseInformation()
{
string id;
switch (courseType)
{
case 'd': id = "HND";
break;
case 'c': id = "HNC";
break;
case 'e': id = "ECDL";
break;
case 'v': id = "Vocational";
break;
case 'r': id = "Recreational";
break;
case 'a': id = "Academic";
break;
default: id = "Unknown";
break;
}
return string.Format(System.Globalization.CultureInfo.InvariantCulture, "{0} {1} {2}", id, Convert.ToString(courseType), Convert.ToString(CourseCode));
}
Regards,
Ian.