So… I want to return value when C# function is called. I need a code example (simple summ of a,b values will be ok) Please help
I need something like this ( I know ActionScript so I will write in it):
public function sum(valueA:int, valueB:int):int
{
var summ:int = valueA + valueB;
return summ;
}
How to translate it into C#?
As a side-note, C# (3.0 above) also supports the
varkeyword when declaring variables, which means that you can write:The meaning of
varis porbably different than in ActionScript – it looks at the expression used to initialize the variable and uses the type of the expression (so the code is statically-typed). In the example above, the type ofsummwill beintjust like in the version posted by Oded.(This is often a confusing thing for people with background in dynamic languages, so I thought it would be useful to mention this, especially since
varis also a keyword in ActionScript).