Results 1 to 4 of 4

Thread: Use of unassigned local variable <resolved>

Threaded View

  1. #1

    Thread Starter
    Hyperactive Member Comreak's Avatar
    Join Date
    Feb 2001
    Location
    Dis
    Posts
    319

    Question Use of unassigned local variable <resolved>

    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:
    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'
    The code:
    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
    Am I missing something here? Thanks for any help in advance.
    Last edited by Comreak; Apr 2nd, 2005 at 03:39 PM.
    C.O.M.R.E.A.K.: Cybernetic Obedient Machine Responsible for Exploration and Accurate Killing

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width