Cannot implicitly convert type int to string? why?

Home Forums C# Programming Cannot implicitly convert type int to string? why?

This topic contains 1 reply, has 2 voices, and was last updated by  msaqib 10 years ago.

  • Author
    Posts
  • #2114

    CRavi
    Member

    Hello i am still new to C#, has been a month now studying this from VS 2008 C# but now i am concentrating more on code than gui interface, i am looking right now if and else and switch, i decied to use a switch since it is new to me, it keeps giving me that error “implicitly convert type into string, for all 4 cases i made, why? all of the code is below:

  • #3405

    msaqib
    Participant

    HelloYou are trying to use string type variable in your switch statement which is expecting an int type variable. Here is how you are doing

    Now the problem is you can not use string type variable in switch statement. You could use it like

    Or you could have use int type variable like

You must be logged in to reply to this topic.