At which line does it complain?
LizR
Posting Virtuoso
1,791 posts since Aug 2008
Reputation Points: 196
Solved Threads: 190
string m = "";m1 = "";m2 = "";
Will never work. My C# compiler must first know the type of m1 and m2 before he will assign something to it.(Perhaps you have a more advanced one?)
Better is to use string m ="", m1="" , m2="";
Or still even better : string m = string.Empty, m1 = string.Empty, m2 = string.Empty;
>>Egypt Pharao : And still even more better would be to give meaningfull names to m,m1 and m2. What are they? I don't know. You will be asking yourself the same question when you see this code after a month or so. Ifm is a fountain pen pen holder(whatever...) then call your variable FountainPenHolder or something like that.
ddanbe
Senior Poster
3,829 posts since Oct 2008
Reputation Points: 2,070
Solved Threads: 661
Initializing the variables is not necessary in this case following the logic you are using.
Set the values of m1 and m2 in the default: case of your switch statement and the problem will be solved.
There is no reason to initialize a variable if you are setting the values in a switch statement with a default case.
sknake
Industrious Poster
4,954 posts since Feb 2009
Reputation Points: 1,764
Solved Threads: 735
Another problem in your code:
You declare int s = 100; in your while loop.
s? anybody any idea what s is?
You never change s when you arrive at switch (s) s is still 100. So you will always execute one case option.
ddanbe
Senior Poster
3,829 posts since Oct 2008
Reputation Points: 2,070
Solved Threads: 661