From eb1ed1729b9d9539e16e17590cfb911cd72a279e Mon Sep 17 00:00:00 2001 From: angelsl Date: Fri, 10 Feb 2017 00:40:04 +0800 Subject: [csharp/en] Add exception filters, pragma directives (#2409) * [csharp/en] Add exception filters, pragma directives * Remove redundant catch --- csharp.html.markdown | 92 ++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 89 insertions(+), 3 deletions(-) (limited to 'csharp.html.markdown') diff --git a/csharp.html.markdown b/csharp.html.markdown index 442700a6..cca99fb0 100644 --- a/csharp.html.markdown +++ b/csharp.html.markdown @@ -1006,15 +1006,101 @@ on a new line! ""Wow!"", the masses cried"; // x?.y will return null immediately if x is null; y is not evaluated => GenieName?.ToUpper(); } + + static class MagicService + { + private static bool LogException(Exception ex) + { + /* log exception somewhere */ + return false; + } + + public static bool CastSpell(string spell) + { + try + { + // Pretend we call API here + throw new MagicServiceException("Spell failed", 42); + + // Spell succeeded + return true; + } + // Only catch if Code is 42 i.e. spell failed + catch(MagicServiceException ex) when (ex.Code == 42) + { + // Spell failed + return false; + } + // Other exceptions, or MagicServiceException where Code is not 42 + catch(Exception ex) when (LogException(ex)) + { + // Execution never reaches this block + // The stack is not unwound + } + return false; + // Note that catching a MagicServiceException and rethrowing if Code + // is not 42 or 117 is different, as then the final catch-all block + // will not catch the rethrown exception + } + } + + public class MagicServiceException : Exception + { + public int Code { get; } + + public MagicServiceException(string message, int code) : base(message) + { + Code = code; + } + } + + public static class PragmaWarning { + // Obsolete attribute + [Obsolete("Use NewMethod instead", false)] + public static void ObsoleteMethod() + { + /* obsolete code */ + } + + public static void NewMethod() + { + /* new code */ + } + + public static void Main() + { + ObsoleteMethod(); // CS0618: 'ObsoleteMethod is obsolete: Use NewMethod instead' +#pragma warning disable CS0618 + ObsoleteMethod(); // no warning +#pragma warning restore CS0618 + ObsoleteMethod(); // CS0618: 'ObsoleteMethod is obsolete: Use NewMethod instead' + } + } } // End Namespace + +using System; +// C# 6, static using +using static System.Math; + +namespace Learning.More.CSharp +{ + class StaticUsing + { + static void Main() + { + // Without a static using statement.. + Console.WriteLine("The square root of 4 is {}.", Math.Sqrt(4)); + // With one + Console.WriteLine("The square root of 4 is {}.", Sqrt(4)); + } + } +} ``` ## Topics Not Covered * Attributes - * async/await, pragma directives - * Exception filters - * `using static` + * async/await * Web Development * ASP.NET MVC & WebApi (new) * ASP.NET Web Forms (old) -- cgit v1.2.3 From 9d0d3a0e342d483278e02ccdefa5eb51073a8899 Mon Sep 17 00:00:00 2001 From: Larry Boltovskoi Date: Wed, 2 Aug 2017 21:03:42 +0200 Subject: Spelling mistake that threw me of while reading --- csharp.html.markdown | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'csharp.html.markdown') diff --git a/csharp.html.markdown b/csharp.html.markdown index cca99fb0..8a631e54 100644 --- a/csharp.html.markdown +++ b/csharp.html.markdown @@ -593,7 +593,7 @@ on a new line! ""Wow!"", the masses cried"; Console.WriteLine(bikeSummary.Name); // ASPARALLEL - // And this is where things get wicked - combines linq and parallel operations + // And this is where things get wicked - combine linq and parallel operations var threeWheelers = bikes.AsParallel().Where(b => b.Wheels == 3).Select(b => b.Name); // this will happen in parallel! Threads will automagically be spun up and the // results divvied amongst them! Amazing for large datasets when you have lots of @@ -613,7 +613,7 @@ on a new line! ""Wow!"", the masses cried"; .ThenBy(b => b.Name) .Select(b => b.Name); // still no query run - // Now the query runs, but opens a reader, so only populates are you iterate through + // Now the query runs, but opens a reader, so only populates as you iterate through foreach (string bike in query) Console.WriteLine(result); -- cgit v1.2.3 From 4ee29d1c256c7587457469da2415ed8997e983e5 Mon Sep 17 00:00:00 2001 From: Ravinder Jangra Date: Thu, 10 Aug 2017 11:22:43 +0530 Subject: C# 7 Feature Tuple --- csharp.html.markdown | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'csharp.html.markdown') diff --git a/csharp.html.markdown b/csharp.html.markdown index cca99fb0..a92f5aa2 100644 --- a/csharp.html.markdown +++ b/csharp.html.markdown @@ -1095,6 +1095,28 @@ namespace Learning.More.CSharp } } } + +using System; +namespace Csharp7 +{ + //New C# 7 Feature + //Install Microsoft.Net.Compilers Latest from Nuget + //Install System.ValueTuple Latest from Nuget + class Program + { + static void Main(string[] args) + { + //Type 1 Declaration + (string FirstName, string LastName) names1 = ("Peter", "Parker"); + Console.WriteLine(names1.FirstName); + + //Type 2 Declaration + var names2 = (First:"Peter", Last:"Parker"); + Console.WriteLine(names2.Last); + } + } +} + ``` ## Topics Not Covered -- cgit v1.2.3 From 16d6dc00ce5255d7e7b0a222436414aad0db0cdd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andre=20Polykanine=20A=2EK=2EA=2E=20Menelion=20Elens=C3=BA?= =?UTF-8?q?l=C3=AB?= Date: Wed, 23 Aug 2017 00:32:47 +0300 Subject: Fixed #2810. Corrected a typo in the CSharp tutorial --- csharp.html.markdown | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'csharp.html.markdown') diff --git a/csharp.html.markdown b/csharp.html.markdown index 8a631e54..78f9db34 100644 --- a/csharp.html.markdown +++ b/csharp.html.markdown @@ -711,7 +711,7 @@ on a new line! ""Wow!"", the masses cried"; // Before .NET 4: (aBike.Accessories & Bicycle.BikeAccessories.Bell) == Bicycle.BikeAccessories.Bell public BikeAccessories Accessories { get; set; } - // Static members belong to the type itself rather then specific object. + // Static members belong to the type itself rather than specific object. // You can access them without a reference to any object: // Console.WriteLine("Bicycles created: " + Bicycle.bicyclesCreated); public static int BicyclesCreated { get; set; } -- cgit v1.2.3 From b01b53a46dbb4d2a35c44ad2caff521f442b2741 Mon Sep 17 00:00:00 2001 From: ksami Date: Mon, 23 Oct 2017 17:36:18 +0800 Subject: clarify use case for verbatim strings added example for using @ symbol with strings --- csharp.html.markdown | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'csharp.html.markdown') diff --git a/csharp.html.markdown b/csharp.html.markdown index 963f38f4..bb8bf6e5 100644 --- a/csharp.html.markdown +++ b/csharp.html.markdown @@ -132,6 +132,12 @@ namespace Learning.CSharp DateTime fooDate = DateTime.Now; Console.WriteLine(fooDate.ToString("hh:mm, dd MMM yyyy")); + // Verbatim String + // You can use the @ symbol before a string literal to escape all characters in the string + string path = "C:\\Users\\User\\Desktop"; + string verbatimPath = "C:\Users\User\Desktop"; + Console.WriteLine(path == verbatimPath); // => true + // You can split a string over two lines with the @ symbol. To escape " use "" string bazString = @"Here's some stuff on a new line! ""Wow!"", the masses cried"; -- cgit v1.2.3 From 3e072363d9b454973f116e39d4690ed73662f452 Mon Sep 17 00:00:00 2001 From: ksami Date: Mon, 23 Oct 2017 17:41:57 +0800 Subject: missed out the @ symbol --- csharp.html.markdown | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'csharp.html.markdown') diff --git a/csharp.html.markdown b/csharp.html.markdown index bb8bf6e5..77737182 100644 --- a/csharp.html.markdown +++ b/csharp.html.markdown @@ -135,7 +135,7 @@ namespace Learning.CSharp // Verbatim String // You can use the @ symbol before a string literal to escape all characters in the string string path = "C:\\Users\\User\\Desktop"; - string verbatimPath = "C:\Users\User\Desktop"; + string verbatimPath = @"C:\Users\User\Desktop"; Console.WriteLine(path == verbatimPath); // => true // You can split a string over two lines with the @ symbol. To escape " use "" -- cgit v1.2.3 From 467f143b9cc3c267d87b295e1ca84ef9308873a2 Mon Sep 17 00:00:00 2001 From: ksami Date: Mon, 23 Oct 2017 17:50:07 +0800 Subject: add example for verbatim interpolated string --- csharp.html.markdown | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'csharp.html.markdown') diff --git a/csharp.html.markdown b/csharp.html.markdown index 77737182..c98a7da9 100644 --- a/csharp.html.markdown +++ b/csharp.html.markdown @@ -955,6 +955,7 @@ on a new line! ""Wow!"", the masses cried"; // String interpolation by prefixing the string with $ // and wrapping the expression you want to interpolate with { braces } + // You can also combine both interpolated and verbatim strings with $@ public class Rectangle { public int Length { get; set; } @@ -967,6 +968,9 @@ on a new line! ""Wow!"", the masses cried"; { Rectangle rect = new Rectangle { Length = 5, Width = 3 }; Console.WriteLine($"The length is {rect.Length} and the width is {rect.Width}"); + + string username = "User"; + Console.WriteLine($@"C:\Users\{username}\Desktop"); } } -- cgit v1.2.3 From 95b5f9a4c4fa17b1d4854185a08e2a3434944de0 Mon Sep 17 00:00:00 2001 From: ksami Date: Tue, 24 Oct 2017 13:29:11 +0800 Subject: #2314 add delegates and events to csharp/en --- csharp.html.markdown | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) (limited to 'csharp.html.markdown') diff --git a/csharp.html.markdown b/csharp.html.markdown index c98a7da9..24ce803e 100644 --- a/csharp.html.markdown +++ b/csharp.html.markdown @@ -640,6 +640,54 @@ on a new line! ""Wow!"", the masses cried"; } } + + // DELEGATES AND EVENTS + public class DelegateTest + { + public static int count = 0; + public static int Increment() + { + // increment count then return it + return ++count; + } + + // A delegate is a reference to a method + // To reference the Increment method, + // first declare a delegate with the same signature + // ie. takes no arguments and returns an int + public delegate int IncrementDelegate(); + + // An event can also be used to trigger delegates + // Create an event with the delegate type + public static event IncrementDelegate MyEvent; + + static void Main(string[] args) + { + // Refer to the Increment method by instantiating the delegate + // and passing the method itself in as an argument + IncrementDelegate inc = new IncrementDelegate(Increment); + Console.WriteLine(inc()); // => 1 + + // Delegates can be composed with the + operator + IncrementDelegate composedInc = inc; + composedInc += inc; + composedInc += inc; + + // composedInc will run Increment 3 times + Console.WriteLine(composedInc()); // => 4 + + + // Subscribe to the event with the delegate + MyEvent += new IncrementDelegate(Increment); + MyEvent += new IncrementDelegate(Increment); + + // Trigger the event + // ie. run all delegates subscribed to this event + Console.WriteLine(MyEvent()); // => 6 + } + } + + // Class Declaration Syntax: // class { // //data fields, constructors, functions all inside. -- cgit v1.2.3 From 4eb33f98b47dfbf6ae0c7c2148faadab310f53c5 Mon Sep 17 00:00:00 2001 From: ksami Date: Tue, 24 Oct 2017 15:20:20 +0800 Subject: add topics for tuples to csharp/en Added explanation and examples for tuples, deconstruction of tuples and other objects, and discarding unwanted fields during deconstruction --- csharp.html.markdown | 72 ++++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 56 insertions(+), 16 deletions(-) (limited to 'csharp.html.markdown') diff --git a/csharp.html.markdown b/csharp.html.markdown index c98a7da9..54d5ea09 100644 --- a/csharp.html.markdown +++ b/csharp.html.markdown @@ -1106,25 +1106,65 @@ namespace Learning.More.CSharp } } +//New C# 7 Feature +//Install Microsoft.Net.Compilers Latest from Nuget +//Install System.ValueTuple Latest from Nuget using System; namespace Csharp7 { - //New C# 7 Feature - //Install Microsoft.Net.Compilers Latest from Nuget - //Install System.ValueTuple Latest from Nuget - class Program - { - static void Main(string[] args) - { - //Type 1 Declaration - (string FirstName, string LastName) names1 = ("Peter", "Parker"); - Console.WriteLine(names1.FirstName); - - //Type 2 Declaration - var names2 = (First:"Peter", Last:"Parker"); - Console.WriteLine(names2.Last); - } - } + // TUPLES, DECONSTRUCTION AND DISCARDS + class TuplesTest + { + public (string, string) GetName() + { + // Fields in tuples are by default named Item1, Item2... + var names1 = ("Peter", "Parker"); + Console.WriteLine(names1.Item2); // => Parker + + // Fields can instead be explicitly named + // Type 1 Declaration + (string FirstName, string LastName) names2 = ("Peter", "Parker"); + + // Type 2 Declaration + var names3 = (First:"Peter", Last:"Parker"); + + Console.WriteLine(names2.FirstName); // => Peter + Console.WriteLine(names3.Last); // => Parker + + return names3; + } + + public string GetLastName() { + var fullName = GetName(); + + // Tuples can be deconstructed + (string firstName, string lastName) = fullName; + + // Fields in a deconstructed tuple can be discarded by using _ + var (_, last) = fullName; + return last; + } + + // Any type can be deconstructed in the same way by + // specifying a Deconstruct method + public int randomNumber = 4; + public int anotherRandomNumber = 10; + + public void Deconstruct(out int randomNumber, out int anotherRandomNumber) + { + randomNumber = this.randomNumber; + anotherRandomNumber = this.anotherRandomNumber; + } + + static void Main(string[] args) + { + var tt = new TuplesTest(); + (int num1, int num2) = tt; + Console.WriteLine($"num1: {num1}, num2: {num2}"); // => num1: 4, num2: 10 + + Console.WriteLine(tt.GetLastName()); + } + } } ``` -- cgit v1.2.3 From 6d836a9fda6ea007d3393799c83f3f12df91affb Mon Sep 17 00:00:00 2001 From: ksami Date: Fri, 27 Oct 2017 14:27:14 +0800 Subject: Add more c#7 features Added pattern matching, reference locals and local functions under c#7 features --- csharp.html.markdown | 79 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 79 insertions(+) (limited to 'csharp.html.markdown') diff --git a/csharp.html.markdown b/csharp.html.markdown index 3790747c..f27adf18 100644 --- a/csharp.html.markdown +++ b/csharp.html.markdown @@ -1213,6 +1213,85 @@ namespace Csharp7 Console.WriteLine(tt.GetLastName()); } } + + // PATTERN MATCHING + class PatternMatchingTest + { + public static (string, int)? CreateLogMessage(object data) + { + switch(data) + { + // Additional filtering using when + case System.Net.Http.HttpRequestException h when h.Message.Contains("404"): + return (h.Message, 404); + case System.Net.Http.HttpRequestException h when h.Message.Contains("400"): + return (h.Message, 400); + case Exception e: + return (e.Message, 500); + case string s: + return (s, s.Contains("Error") ? 500 : 200); + case null: + return null; + default: + return (data.ToString(), 500); + } + } + } + + // REFERENCE LOCALS + // Allow you to return a reference to an object instead of just its value + class RefLocalsTest + { + // note ref in return + public static ref string FindItem(string[] arr, string el) + { + for(int i=0; i apple + } + } + + // LOCAL FUNCTIONS + class LocalFunctionTest + { + private static int _id = 0; + public int id; + public LocalFunctionTest() + { + id = generateId(); + + // This local function can only be accessed in this scope + int generateId() + { + return _id++; + } + } + + public static void AnotherMethod() + { + var lf1 = new LocalFunctionTest(); + var lf2 = new LocalFunctionTest(); + Console.WriteLine($"{lf1.id}, {lf2.id}"); // => 0, 1 + + int id = generateId(); + // error CS0103: The name 'generateId' does not exist in the current context + } + } } ``` -- cgit v1.2.3 From ca326545134d0c43913dfa9f5f9c24e6871fd7aa Mon Sep 17 00:00:00 2001 From: ken Date: Mon, 29 Apr 2019 17:07:55 -0400 Subject: typo fix in csharp.html.markdown --- csharp.html.markdown | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'csharp.html.markdown') diff --git a/csharp.html.markdown b/csharp.html.markdown index f27adf18..df6544d3 100644 --- a/csharp.html.markdown +++ b/csharp.html.markdown @@ -344,7 +344,7 @@ on a new line! ""Wow!"", the masses cried"; tryInt.ToString(); // Casting - // Cast decimal 15 to a int + // Cast decimal 15 to an int // and then implicitly cast to long long x = (int) 15M; } -- cgit v1.2.3 From 3ade005c37a40c8e1712f6c68c81ebc9682a36c1 Mon Sep 17 00:00:00 2001 From: Chris Zimmerman Date: Mon, 30 Sep 2019 18:11:43 -0400 Subject: Fixes the spacing of comments in the English C# documentation --- csharp.html.markdown | 42 ++++++++++++++++++++++-------------------- 1 file changed, 22 insertions(+), 20 deletions(-) (limited to 'csharp.html.markdown') diff --git a/csharp.html.markdown b/csharp.html.markdown index df6544d3..0cf59762 100644 --- a/csharp.html.markdown +++ b/csharp.html.markdown @@ -18,16 +18,18 @@ C# is an elegant and type-safe object-oriented language that enables developers ```c# // Single-line comments start with // + /* 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 /// /// This is some parameter documentation for firstParam /// Information on the returned value of a function -//public void MethodOrClassOrOtherWithParsableHelp(string firstParam) {} +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 Library @@ -254,7 +256,7 @@ on a new line! ""Wow!"", the masses cried"; int fooWhile = 0; while (fooWhile < 100) { - //Iterated 100 times, fooWhile 0->99 + // Iterated 100 times, fooWhile 0->99 fooWhile++; } @@ -273,10 +275,10 @@ on a new line! ""Wow!"", the masses cried"; } while (fooDoWhile < 100); - //for loop structure => for(; ; ) + // for loop structure => for(; ; ) for (int fooFor = 0; fooFor < 10; fooFor++) { - //Iterated 10 times, fooFor 0->9 + // Iterated 10 times, fooFor 0->9 } // For Each Loop @@ -287,7 +289,7 @@ on a new line! ""Wow!"", the masses cried"; // (The ToCharArray() could be removed, because a string also implements IEnumerable) foreach (char character in "Hello World".ToCharArray()) { - //Iterated over all the characters in the string + // Iterated over all the characters in the string } // Switch Case @@ -329,7 +331,7 @@ on a new line! ""Wow!"", the masses cried"; // Convert String To Integer // this will throw a FormatException on failure - int.Parse("123");//returns an integer version of "123" + int.Parse("123"); // returns an integer version of "123" // try parse will default to type default on failure // in this case: 0 @@ -373,7 +375,7 @@ on a new line! ""Wow!"", the masses cried"; Console.Read(); } // End main method - // CONSOLE ENTRY A console application must have a main method as an entry point + // CONSOLE ENTRY - A console application must have a main method as an entry point public static void Main(string[] args) { OtherInterestingFeatures(); @@ -404,7 +406,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 + // 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 } @@ -564,11 +566,11 @@ on a new line! ""Wow!"", the masses cried"; } ); - //Running this will produce different outputs - //since each thread finishes at different times. - //Some example outputs are: - //cat dog horse pony - //dog horse pony cat + // Running this will produce different outputs + // since each thread finishes at different times. + // Some example outputs are: + // cat dog horse pony + // dog horse pony cat // DYNAMIC OBJECTS (great for working with other languages) dynamic student = new ExpandoObject(); @@ -865,7 +867,7 @@ on a new line! ""Wow!"", the masses cried"; } } - //Method to display the attribute values of this Object. + // Method to display the attribute values of this Object. public virtual string Info() { return "Gear: " + Gear + @@ -1069,7 +1071,7 @@ on a new line! ""Wow!"", the masses cried"; { private static bool LogException(Exception ex) { - /* log exception somewhere */ + // log exception somewhere return false; } @@ -1117,12 +1119,12 @@ on a new line! ""Wow!"", the masses cried"; [Obsolete("Use NewMethod instead", false)] public static void ObsoleteMethod() { - /* obsolete code */ + // obsolete code } public static void NewMethod() { - /* new code */ + // new code } public static void Main() @@ -1154,9 +1156,9 @@ namespace Learning.More.CSharp } } -//New C# 7 Feature -//Install Microsoft.Net.Compilers Latest from Nuget -//Install System.ValueTuple Latest from Nuget +// New C# 7 Feature +// Install Microsoft.Net.Compilers Latest from Nuget +// Install System.ValueTuple Latest from Nuget using System; namespace Csharp7 { -- cgit v1.2.3 From b2e762307e064843059a5e649f3e7016032e8d74 Mon Sep 17 00:00:00 2001 From: Apoorv Choubey Date: Sat, 12 Oct 2019 21:08:56 +0530 Subject: add CSharp resource --- csharp.html.markdown | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'csharp.html.markdown') diff --git a/csharp.html.markdown b/csharp.html.markdown index df6544d3..139010c7 100644 --- a/csharp.html.markdown +++ b/csharp.html.markdown @@ -725,10 +725,10 @@ on a new line! ""Wow!"", the masses cried"; int _speed; // Everything is private by default: Only accessible from within this class. // can also use keyword private public string Name { get; set; } - + // Properties also have a special syntax for when you want a readonly property // that simply returns the result of an expression - public string LongName => Name + " " + _speed + " speed"; + public string LongName => Name + " " + _speed + " speed"; // Enum is a value type that consists of a set of named constants // It is really just mapping a name to a value (an int, unless specified otherwise). @@ -1089,7 +1089,7 @@ on a new line! ""Wow!"", the masses cried"; // Spell failed return false; } - // Other exceptions, or MagicServiceException where Code is not 42 + // Other exceptions, or MagicServiceException where Code is not 42 catch(Exception ex) when (LogException(ex)) { // Execution never reaches this block @@ -1213,7 +1213,7 @@ namespace Csharp7 Console.WriteLine(tt.GetLastName()); } } - + // PATTERN MATCHING class PatternMatchingTest { @@ -1320,3 +1320,4 @@ namespace Csharp7 * [ASP.NET Web Forms Tutorials](http://www.asp.net/web-forms/tutorials) * [Windows Forms Programming in C#](http://www.amazon.com/Windows-Forms-Programming-Chris-Sells/dp/0321116208) * [C# Coding Conventions](http://msdn.microsoft.com/en-us/library/vstudio/ff926074.aspx) + * [freeCodeCamp - C# Tutorial for Beginners](https://www.youtube.com/watch?v=GhQdlIFylQ8) -- cgit v1.2.3 From b919dc6f30bceab40d21de4e0454f6610268d5ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B0=AD=E4=B9=9D=E9=BC=8E?= <109224573@qq.com> Date: Mon, 18 Nov 2019 16:22:38 +0800 Subject: [C#/en] Update some urls --- csharp.html.markdown | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) (limited to 'csharp.html.markdown') diff --git a/csharp.html.markdown b/csharp.html.markdown index df6544d3..a83df967 100644 --- a/csharp.html.markdown +++ b/csharp.html.markdown @@ -14,7 +14,7 @@ filename: LearnCSharp.cs C# is an elegant and type-safe object-oriented language that enables developers to build a variety of secure and robust applications that run on the .NET Framework. -[Read more here.](http://msdn.microsoft.com/en-us/library/vstudio/z1zx9t92.aspx) +[Read more here.](https://docs.microsoft.com/dotnet/csharp/getting-started/introduction-to-the-csharp-language-and-the-net-framework) ```c# // Single-line comments start with // @@ -552,7 +552,7 @@ on a new line! ""Wow!"", the masses cried"; } // PARALLEL FRAMEWORK - // http://blogs.msdn.com/b/csharpfaq/archive/2010/06/01/parallel-programming-in-net-framework-4-getting-started.aspx + // https://devblogs.microsoft.com/csharpfaq/parallel-programming-in-net-framework-4-getting-started/ var words = new List {"dog", "cat", "horse", "pony"}; @@ -960,7 +960,7 @@ on a new line! ""Wow!"", the masses cried"; /// /// Used to connect to DB for LinqToSql example. /// EntityFramework Code First is awesome (similar to Ruby's ActiveRecord, but bidirectional) - /// http://msdn.microsoft.com/en-us/data/jj193542.aspx + /// https://docs.microsoft.com/ef/ef6/modeling/code-first/workflows/new-database /// public class BikeRepository : DbContext { @@ -1310,13 +1310,11 @@ namespace Csharp7 ## Further Reading - * [DotNetPerls](http://www.dotnetperls.com) - * [C# in Depth](http://manning.com/skeet2) - * [Programming C#](http://shop.oreilly.com/product/0636920024064.do) - * [LINQ](http://shop.oreilly.com/product/9780596519254.do) - * [MSDN Library](http://msdn.microsoft.com/en-us/library/618ayhy6.aspx) - * [ASP.NET MVC Tutorials](http://www.asp.net/mvc/tutorials) - * [ASP.NET Web Matrix Tutorials](http://www.asp.net/web-pages/tutorials) - * [ASP.NET Web Forms Tutorials](http://www.asp.net/web-forms/tutorials) - * [Windows Forms Programming in C#](http://www.amazon.com/Windows-Forms-Programming-Chris-Sells/dp/0321116208) - * [C# Coding Conventions](http://msdn.microsoft.com/en-us/library/vstudio/ff926074.aspx) + * [C# language reference](https://docs.microsoft.com/dotnet/csharp/language-reference/) + * [Learn .NET](https://dotnet.microsoft.com/learn) + * [C# Coding Conventions](https://docs.microsoft.com/en-us/dotnet/csharp/programming-guide/inside-a-program/coding-conventions) + * [DotNetPerls](https://www.dotnetperls.com/) + * [C# in Depth](https://manning.com/skeet3) + * [Programming C# 5.0](http://shop.oreilly.com/product/0636920024064) + * [LINQ Pocket Reference](http://shop.oreilly.com/product/9780596519254) + * [Windows Forms Programming in C#](https://www.amazon.com/Windows-Forms-Programming-Chris-Sells/dp/0321116208) -- cgit v1.2.3 From 2432006a8d11a7e0bdcc976f1ec0bd6262a67245 Mon Sep 17 00:00:00 2001 From: Ajit Panigrahi Date: Wed, 11 Dec 2019 12:29:57 +0530 Subject: Updated grammar - An ambiguous sentence, needed full stop (.) - "i.e." instead of "ie." --- csharp.html.markdown | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'csharp.html.markdown') diff --git a/csharp.html.markdown b/csharp.html.markdown index 37573e01..99c76dff 100644 --- a/csharp.html.markdown +++ b/csharp.html.markdown @@ -653,10 +653,10 @@ on a new line! ""Wow!"", the masses cried"; return ++count; } - // A delegate is a reference to a method + // A delegate is a reference to a method. // To reference the Increment method, - // first declare a delegate with the same signature - // ie. takes no arguments and returns an int + // first declare a delegate with the same signature, + // i.e. takes no arguments and returns an int public delegate int IncrementDelegate(); // An event can also be used to trigger delegates -- cgit v1.2.3