#region Example
if (Statement1 == 1)
if (Statement2 == 2)
switch (Statement3)
{
case 1:
if (Statement1 == Statement 2)
Statement4++;
break;
}
#endregion
Umm... that would depend on what the statements are and why you would code anything that way?
in that you will never get statement4 to increase because you are requiring 1 and 2 to be different things and then checking for statement 3 to see if they are equal to modify statement 4.
Honestly what does this have to do with ANYTHING? :S....
Personally you should be doing a switch based on the type and then handle the other statements. As you have it right now, yes it will 'work' in that it will flow through properly but it will never actually execute anything.
Umm... that would depend on what the statements are and why you would code anything that way?
in that you will never get statement4 to increase because you are requiring 1 and 2 to be different things and then checking for statement 3 to see if they are equal to modify statement 4.
Honestly what does this have to do with ANYTHING? :S....
Personally you should be doing a switch based on the type and then handle the other statements. As you have it right now, yes it will 'work' in that it will flow through properly but it will never actually execute anything.
I'm just using them as examples of what i'm trying to code.
I'm trying to code my own source and I want it to be as organized as possible with less brackets everywhere. All i'm asking is if it works without the brackets like that. The indentation looks like it will.
Yah you don't need brackets to force indentation but keep in mind if statements only control the next line if you don't use brackets.
IE
if(Blah)
do action1
do action2
will only do action 1. To have it do both you'd need to surround them by brackets.
Switch statements are good any time you have more than a few things to discern between (IE: 3-4+ conditions I'd try to work it into a switch statement)
Yah you don't need brackets to force indentation but keep in mind if statements only control the next line if you don't use brackets.
IE
if(Blah)
do action1
do action2
will only do action 1. To have it do both you'd need to surround them by brackets.
Switch statements are good any time you have more than a few things to discern between (IE: 3-4+ conditions I'd try to work it into a switch statement)
I know that much =P
Thanks for confirming though!
Quote:
Originally Posted by _tao4229_
It depends on how you want it really.
If you're developing by yourself just do it how you want it.
#region Example
if (Statement1 == 1)
if (Statement2 == 2)
switch (Statement3)
{
case 1:
if (Statement1 == Statement 2)
Statement4++;
break;
}
#endregion
Thanks!
Sincerely,
Fang
In all honesty it's up to you. In my opinion: no.
I'd argue if your code was,
Code:
if (s == 1)
if (s2 == 2)
Method();
That's fine.
But, if you're going to need to open up a scope (breaking out the curly brackets), then I would surround every statement with curly braces, i.e.
Code:
if (s == 1)
{
if (s2 == 2)
{
Method();
Method2();
Method3();
}
}
verses;
Code:
if (s == 1)
if (s2 == 2)
{
Method();
Method2();
Method3();
}
Quote:
Originally Posted by _tao4229_
It depends on how you want it really.
If you're developing by yourself just do it how you want it.
I prefer to put my { at the end of lines
Code:
int f(int x) {
....
}
but that's just me.
Heard you like using lowercase method names, and instead of properties using getElement() and setElement(), bro'.
Quote:
Originally Posted by pro4never
Yah you don't need brackets to force indentation but keep in mind if statements only control the next line if you don't use brackets.
IE
if(Blah)
do action1
do action2
will only do action 1. To have it do both you'd need to surround them by brackets.
Switch statements are good any time you have more than a few things to discern between (IE: 3-4+ conditions I'd try to work it into a switch statement)
Two things:
I don't know if you explained it because you think what he put in his code-quote wouldn't execute properly -- but to clarify, it'll run perfectly fine.
Secondly, using a switch-statement where it isn't necessary (as you said, under 3-4 cases) will be converted at compile-time to if-statements (assuming code optimizations is enabled -- but hey, why would you turn it off?).
I always put brackets after if statements, even if only one method comes after it, simply because I like it this way Oh and I never put the { like most Java programmers do, I find it irritating.
I almost always use brackets no matter if it's for a switch statement or an if statement or almost any statement. For switch statements the reason you should use brackets is
1. It looks cleaner and more organized (In my eyes atleast).
2. If you wish to have 2 different variables, say a ushort and a double value with the same variable name (example y and y), then you must seperate the cases with brackets so that the variables are not conflicting within the same declaration space introduced by the switch statement.
For brackets with if statements, using brackets simplifies future work incase you have to add more within the if statement, and ontop of that it looks better and is more organized (atleast in my eyes).
class Program
{
static int cookies;
static void Main(string[] args) {
int HowManyCookies = int.Parse(Console.ReadLine());
Cookie(HowManyCookies);
Console.WriteLine(Message(cookies)); }
static int Cookie(int value) { cookies = value; return value; }
static string Message(int Cookies) {
if (Cookies > 0) {
return "You have cookies!";
}
else { return "You have no cookies!"; }
}
}
Code:
class Program
{
public static int Cookies { get; private set; }
static void Main(string[] args)
{
Cookies = int.Parse(Console.ReadLine());
Console.WriteLine(Cookies > 0 ? "You have cookies!" : "You have no coookies!");
}
}
Coding npc(last question) 06/17/2010 - CO2 Private Server - 20 Replies hi, i have conquer pserver,
i need a video who show me all the steps of changing the price of an npc( breeder for exemple)
pelase guys, i know it's a lot but i'm so needding it
thanks
[Question]Syntax for Pet.. 03/22/2010 - EO PServer Hosting - 5 Replies Hey, You know when you compose on top left it says " So and so have composed so and so." well something like that, Whats the Syntax for the pet? Like the Syntax %user_name = Display of the character name. I need to where i can find it and after 50* where the orange fireworks and the GM broadcast saying "So and so's pet is this many stars congratz"
http://i430.photobucket.com/albums/qq23/MikeMadMa n_album/lol-1.jpg
Just all smudgy cuz i wanna keep my privacy O_O
Thanks.
Question About Coding... 07/03/2008 - Conquer Online 2 - 12 Replies Ok I Need Sum Help With A PvP Server It Has infinity Stamina taths noth the probleem but HERC is (they spam it like hell ) How Could Our Team Delet Skill "Herc" or make the command admin Thx For Help If u Wanne Join Us go TO DragonCO :P