Jump to content

Noob C# Help

mooommo
Go to solution Solved by xXxYOLOxSWAGxXx_420BlazeIt,

Thank you, just a few questions, would "dongus(55,4) be? Due to it being a fight it would probably a boolean for victory or loss right?

In my example I used a method that took two integers as its parameters, and returned an integer. You can use any mixture of any data types you want.

 

Dongus can be replaced by any name for the method you would like.

How can I store code, I need to be able to use a "while" loop for a fight scene a lot of times and I don't want to have to copy and paste it so many times. I am at school, and I can't use anything else than IE right now so I can't paste the code or a link to the code so just imagine a few (like 30) lines of code that needs to be used a lot of times.

Intel i7-3770k @ 4.5 GHz                               DCUII GTX 680                            16GB Corsair Vengeance RAM

Sabertooth Z77 ATX                                      WD Caviar Blue 500GB+ 1TB      Corsair Obsidian 750D

Corsair TX850M Watt PSU                            Bad Custom Water Cooling          Samsung 840 Pro SSD

Link to comment
Share on other sites

Link to post
Share on other sites

Put it in a method and just call that method where you need it.

public int dongus(int num1, int num2){     int num3 = 0;     while(num1 > num2){         num3+= num2;     }     return num3;}

Then later on in your code you can just do:

int whatever = dongus(55, 4);
Link to comment
Share on other sites

Link to post
Share on other sites

 

Put it in a method and just call that method where you need it.

public int dongus(int num1, int num2){     int num3 = 0;     while(num1 > num2){         num3+= num2;     }     return num3;}

Then later on in your code you can just do:

int whatever = dongus(55, 4);

^ this, it is probably going to be the most efficient in your case

Link to comment
Share on other sites

Link to post
Share on other sites

 

Put it in a method and just call that method where you need it.

public int dongus(int num1, int num2){     int num3 = 0;     while(num1 > num2){         num3+= num2;     }     return num3;}

Then later on in your code you can just do:

int whatever = dongus(55, 4);

Thank you, just a few questions, would "dongus(55,4) be? Due to it being a fight it would probably a boolean for victory or loss right?

Intel i7-3770k @ 4.5 GHz                               DCUII GTX 680                            16GB Corsair Vengeance RAM

Sabertooth Z77 ATX                                      WD Caviar Blue 500GB+ 1TB      Corsair Obsidian 750D

Corsair TX850M Watt PSU                            Bad Custom Water Cooling          Samsung 840 Pro SSD

Link to comment
Share on other sites

Link to post
Share on other sites

Thank you, just a few questions, would "dongus(55,4) be? Due to it being a fight it would probably a boolean for victory or loss right?

In my example I used a method that took two integers as its parameters, and returned an integer. You can use any mixture of any data types you want.

 

Dongus can be replaced by any name for the method you would like.

Link to comment
Share on other sites

Link to post
Share on other sites

xXxYOLOxSWAGxXx_420BlazeIt, on 26 Mar 2014 - 11:31 AM, said:

In my example I used a method that took two integers as its parameters, and returned an integer. You can use any mixture of any data types you want.

 

Dongus can be replaced by any name for the method you would like.

okay, great. Thank you very much.

Intel i7-3770k @ 4.5 GHz                               DCUII GTX 680                            16GB Corsair Vengeance RAM

Sabertooth Z77 ATX                                      WD Caviar Blue 500GB+ 1TB      Corsair Obsidian 750D

Corsair TX850M Watt PSU                            Bad Custom Water Cooling          Samsung 840 Pro SSD

Link to comment
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×