diff options
| author | Lidenburg <richard.lindberg1997@gmail.com> | 2016-03-15 18:56:44 +0100 | 
|---|---|---|
| committer | Lidenburg <richard.lindberg1997@gmail.com> | 2016-03-15 18:56:44 +0100 | 
| commit | ce5183bd3d38094401ec37b691fb11c08ec3a07f (patch) | |
| tree | 6227674189be0b6ae719f956c800de98daa4b283 /csharp.html.markdown | |
| parent | c38933a4d187bb2f7a13b1716e9c6d884b390e89 (diff) | |
| parent | 2095ad9cf5f3243296be5a7232dc52ae03603f49 (diff) | |
Merge remote-tracking branch 'refs/remotes/adambard/master'
Diffstat (limited to 'csharp.html.markdown')
| -rw-r--r-- | csharp.html.markdown | 39 | 
1 files changed, 22 insertions, 17 deletions
| diff --git a/csharp.html.markdown b/csharp.html.markdown index dfdd98de..7be34fb9 100644 --- a/csharp.html.markdown +++ b/csharp.html.markdown @@ -24,10 +24,12 @@ Multi-line comments look like this  /// This is an XML documentation comment which can be used to generate external  /// documentation or provide context help within an IDE  /// </summary> -//public void MethodOrClassOrOtherWithParsableHelp() {} +/// <param name="firstParam">This is some parameter documentation for firstParam</param> +/// <returns>Information on the returned value of a function</returns> +//public void MethodOrClassOrOtherWithParsableHelp(string firstParam) {}  // Specify the namespaces this source code will be using -// The namespaces below are all part of the standard .NET Framework Class Libary +// The namespaces below are all part of the standard .NET Framework Class Library  using System;  using System.Collections.Generic;  using System.Dynamic; @@ -45,8 +47,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 @@ -421,7 +423,7 @@ on a new line! ""Wow!"", the masses cried";                  // Item is an int                  Console.WriteLine(item.ToString());          } -         +          // YIELD          // Usage of the "yield" keyword indicates that the method it appears in is an Iterator          // (this means you can use it in a foreach loop) @@ -437,7 +439,7 @@ on a new line! ""Wow!"", the masses cried";              foreach (var counter in YieldCounter())                  Console.WriteLine(counter);          } -         +          // you can use more than one "yield return" in a method          public static IEnumerable<int> ManyYieldCounter()          { @@ -446,7 +448,7 @@ on a new line! ""Wow!"", the masses cried";              yield return 2;              yield return 3;          } -         +          // you can also use "yield break" to stop the Iterator          // this method would only return half of the values from 0 to limit.          public static IEnumerable<int> YieldCounterWithBreak(int limit = 10) @@ -482,7 +484,7 @@ on a new line! ""Wow!"", the masses cried";              // ?? is syntactic sugar for specifying default value (coalesce)              // in case variable is null              int notNullable = nullable ?? 0; // 0 -             +              // ?. is an operator for null-propagation - a shorthand way of checking for null              nullable?.Print(); // Use the Print() extension method if nullable isn't null @@ -630,7 +632,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()); @@ -692,7 +694,10 @@ on a new line! ""Wow!"", the masses cried";          public BikeBrand Brand; // After declaring an enum type, we can declare the field of this type          // Decorate an enum with the FlagsAttribute to indicate that multiple values can be switched on -        [Flags] // Any class derived from Attribute can be used to decorate types, methods, parameters etc +        // Any class derived from Attribute can be used to decorate types, methods, parameters etc +        // Bitwise operators & and | can be used to perform and/or operations + +        [Flags]          public enum BikeAccessories          {              None = 0, @@ -879,8 +884,8 @@ on a new line! ""Wow!"", the masses cried";          bool Broken { get; } // interfaces can contain properties as well as methods & events      } -    // Class can inherit only one other class, but can implement any amount of interfaces, however -    // the base class name must be the first in the list and all interfaces follow +    // Classes can inherit only one other class, but can implement any amount of interfaces, +    // however the base class name must be the first in the list and all interfaces follow      class MountainBike : Bicycle, IJumpable, IBreakable      {          int damage = 0; @@ -913,17 +918,17 @@ 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 partial class A      {          public static void A1()          {              Console.WriteLine("Method A1 in class A");          }      } -     +      // A2.cs      public partial class A      { @@ -932,9 +937,9 @@ on a new line! ""Wow!"", the masses cried";              Console.WriteLine("Method A2 in class A");          }      } -     +      // Program using the partial class "A" -    public class Program  +    public class Program      {          static void Main()          { | 
