0
How to exit from the code in C#
If i write letter e in the code for example, How can I make it exit?
12 odpowiedzi
+ 6
Environment.Exit(int)
Parameter is the exitcode.
+ 4
Ipang No, it's one of his cases. He is making a calculator and case '/' was adding the numbers instead of making a division. ^^
+ 3
Could you show your code please? That will help other users to understand what you try to do!
+ 2
Do you mean exiting from a loop? You could use "break" for that.
+ 1
Thanks, I fixed the bug
But the/ Environment.Exit(1) / is not working..
0
It doesn't worked!
I want to make the whole program exit...
Get it?
0
int n1,n2;
Char r;
Console.WriteLine("Enter a number");
n1=int.Parse(Console.ReadLine());
Console.WriteLine("Enter an Operation:-,+,*,/,e");
r=Char.Parse(Console.ReadLine());
Console.WriteLine("Enter a number");
n2=int.Parse(Console.ReadLine());
switch(r)
{
case '+':
Console.WriteLine(n1 + n2);
break;
case '-':
Console.WriteLine(n1 - n2);
break;
case '*':
Console.WriteLine(n1 * n2);
break;
case '/':
Console.WriteLine(n1 / n2);
break;
case'e':
break;
}
0
It's working now
But I don't know how to let letter e *for example* to let it exit..
0
case 'e':
Environment.Exit(1);
break;
(fyi: Case '/' has a bug ^^)
0
Alex,
What's with the '/' thing? like needed to be escaped or what?
0
Hii