summaryrefslogtreecommitdiffhomepage
path: root/csharp.html.markdown
diff options
context:
space:
mode:
Diffstat (limited to 'csharp.html.markdown')
-rw-r--r--csharp.html.markdown37
1 files changed, 34 insertions, 3 deletions
diff --git a/csharp.html.markdown b/csharp.html.markdown
index 7aca2c6f..7d7f4340 100644
--- a/csharp.html.markdown
+++ b/csharp.html.markdown
@@ -7,6 +7,7 @@ contributors:
- ["Shaun McCarthy", "http://www.shaunmccarthy.com"]
- ["Wouter Van Schandevijl", "http://github.com/laoujin"]
- ["Jo Pearce", "http://github.com/jdpearce"]
+ - ["Chris Zimmerman", "https://github.com/chriszimmerman"]
filename: LearnCSharp.cs
---
@@ -44,8 +45,8 @@ using System.Data.Entity;
// Using this code from another source file: using Learning.CSharp;
namespace Learning.CSharp
{
- // Each .cs file should at least contain a class with the same name as the file
- // you're allowed to do otherwise, but shouldn't for sanity.
+ // Each .cs file should at least contain a class with the same name as the file.
+ // You're allowed to do otherwise, but shouldn't for sanity.
public class LearnCSharp
{
// BASIC SYNTAX - skip to INTERESTING FEATURES if you have used Java or C++ before
@@ -394,6 +395,7 @@ on a new line! ""Wow!"", the masses cried";
ref int maxCount, // Pass by reference
out int count)
{
+ //the argument passed in as 'count' will hold the value of 15 outside of this function
count = 15; // out param must be assigned before control leaves the method
}
@@ -628,7 +630,7 @@ on a new line! ""Wow!"", the masses cried";
public static class Extensions
{
- // EXTENSION FUNCTIONS
+ // EXTENSION METHODS
public static void Print(this object obj)
{
Console.WriteLine(obj.ToString());
@@ -911,6 +913,35 @@ on a new line! ""Wow!"", the masses cried";
public DbSet<Bicycle> Bikes { get; set; }
}
+
+ // Classes can be split across multiple .cs files
+ // A1.cs
+ public partial class A
+ {
+ public static void A1()
+ {
+ Console.WriteLine("Method A1 in class A");
+ }
+ }
+
+ // A2.cs
+ public partial class A
+ {
+ public static void A2()
+ {
+ Console.WriteLine("Method A2 in class A");
+ }
+ }
+
+ // Program using the partial class "A"
+ public class Program
+ {
+ static void Main()
+ {
+ A.A1();
+ A.A2();
+ }
+ }
} // End Namespace
```