A function allows you to encapsulate a piece of code and
call it from other parts of your code.
<visibility> <return type> <name>(<parameters>)
{
<function code>
}
Example:
Here is an example of our DoStuff()
function:
public
void DoStuff()
{
Console.WriteLine("I'm doing
something...");
}
Example 2:
public int AddNumbers(int number1, int number2)
{
int result = number1 + number2;
return result;
}
Next Chapter
No comments:
Post a Comment