summaryrefslogtreecommitdiffhomepage
path: root/csharp.html.markdown
diff options
context:
space:
mode:
authorLaoujin <woutervs@hotmail.com>2015-01-31 21:45:13 +0100
committerLaoujin <woutervs@hotmail.com>2015-01-31 21:45:13 +0100
commit04c4433433f313884fe38f126b24ff52b59f3af1 (patch)
tree2925987baf548aa0b11969e0c2d367a9de903604 /csharp.html.markdown
parent69e38974aec4d149944e551867c1412dfcf2bed7 (diff)
[CSharp/en]Added ref and out parameters
Diffstat (limited to 'csharp.html.markdown')
-rw-r--r--csharp.html.markdown13
1 files changed, 13 insertions, 0 deletions
diff --git a/csharp.html.markdown b/csharp.html.markdown
index fceda4ff..8eda5356 100644
--- a/csharp.html.markdown
+++ b/csharp.html.markdown
@@ -381,6 +381,15 @@ on a new line! ""Wow!"", the masses cried";
}
// Methods can have the same name, as long as the signature is unique
+ // A method that differs only in return type is not unique
+ public static void MethodSignatures(
+ ref int maxCount, // Pass by reference
+ out int count)
+ {
+ count = 15; // out param must be assigned before control leaves the method
+ }
+
+ // Methods can have the same name, as long as the signature is unique
public static void MethodSignatures(string maxCount)
{
}
@@ -414,6 +423,10 @@ on a new line! ""Wow!"", the masses cried";
MethodSignatures(3, 1, 3, "Some", "Extra", "Strings");
MethodSignatures(3, another: 3); // explicity set a parameter, skipping optional ones
+ // BY REF AND OUT PARAMETERS
+ int maxCount = 0, count; // ref params must have value
+ MethodSignatures(ref maxCount, out count);
+
// EXTENSION METHODS
int i = 3;
i.Print(); // Defined below