Possible class function in C# -


i have class created:

public class character {     public string name, owner;     public int str, con, dex, int, wis, cha, ac, speed, maxhp, currhp, ap, sv, surges; } 

as can see, it's simple class @ moment. question is, there way create class inside when call function can have math equation returned?

example:

character c = new character(); c.name = "goofy"; c.owner = "me"; c.str = 15; messagebox.show(c.str.mod); 

the output window "7" (mod is: math.floor(str / 2);)

i have been trying search both , google time , have yet figure out. may searching wrong phrases or might not possible.

thanks

only way can think extension methods

class program {     static void main(string[] args)     {         character c = new character();         c.name = "goofy";         c.owner = "me";         c.str = 15;         console.writeline(c.str.mod());         console.read();     } }  public class character {     public string name, owner;     public int str, con, dex, int, wis, cha, ac, speed, maxhp, currhp, ap, sv, surges; }  public static class ext {     public static int mod(this int value)     {         return (int)math.floor(value / 2.0);     } } 

Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -