It really depends on where that code is: if it's part of your Main method, then teh simplest solution is just
if(i > 10)
{
Console.WriteLine("num not ok ");
return -1;
}
else
The return statement exits the current method immediately, and in the case of the Main method, that also ends the program - the integer that you return is passed to the system as a "reason for exit" where zero is "normal exit" and any nonm-zero value is an error code.
If you aren't in the Main function, then you need to use
Environment.Exit(-1);
instead of
return