This is driving me insane. I'm sure the mistake is rediculously simple to see but I can't figure it out. Maybe you guys can see what I'm doing wrong...
The error:
The code:Code:error CS0165: Use of unassigned local variable 'carType' error CS0165: Use of unassigned local variable 'carMake' error CS0165: Use of unassigned local variable 'carColor'
Am I missing something here? Thanks for any help in advance.Code:string carColor; string carMake; string carType; switch(carList[lstMadeCars.SelectedIndex].GetType().Name) { case "Car": { carColor = ((Car)carList[lstMadeCars.SelectedIndex]).aCarColor.ToString(); carMake = ((Car)carList[lstMadeCars.SelectedIndex]).aCarMake.ToString(); carType = ((Car)carList[lstMadeCars.SelectedIndex]).aCarType.ToString(); break; } case "SportsCar": { carColor = ((SportsCar)carList[lstMadeCars.SelectedIndex]).aCarColor.ToString(); carMake = ((SportsCar)carList[lstMadeCars.SelectedIndex]).aCarMake.ToString(); carType = ((SportsCar)carList[lstMadeCars.SelectedIndex]).aCarType.ToString(); break; } } lblResult.Text = carType + "\n" + carMake + " " + carColor; //carType, carMake, and carColor where all underlined by VS on this line




Reply With Quote