diff --git a/snippets/csharp/new-in-6/Enrollment.cs b/snippets/csharp/new-in-6/Enrollment.cs deleted file mode 100644 index 8ff57969bfe..00000000000 --- a/snippets/csharp/new-in-6/Enrollment.cs +++ /dev/null @@ -1,27 +0,0 @@ -using System.Collections; -using System.Collections.Generic; - -namespace NewStyle -{ - // - public class Enrollment : IEnumerable - { - private List allStudents = new List(); - - public void Enroll(Student s) - { - allStudents.Add(s); - } - - public IEnumerator GetEnumerator() - { - return ((IEnumerable)allStudents).GetEnumerator(); - } - - IEnumerator IEnumerable.GetEnumerator() - { - return ((IEnumerable)allStudents).GetEnumerator(); - } - } - // -} \ No newline at end of file diff --git a/snippets/csharp/new-in-6/ExceptionFilterHelpers.cs b/snippets/csharp/new-in-6/ExceptionFilterHelpers.cs deleted file mode 100644 index 06c5aa4d9fc..00000000000 --- a/snippets/csharp/new-in-6/ExceptionFilterHelpers.cs +++ /dev/null @@ -1,15 +0,0 @@ -using System; - -namespace NewStyle -{ - public static class ExceptionExtensions - { - // - public static bool LogException(this Exception e) - { - Console.Error.WriteLine($"Exceptions happen: {e}"); - return false; - } - // - } -} diff --git a/snippets/csharp/new-in-6/NetworkClient.cs b/snippets/csharp/new-in-6/NetworkClient.cs index 596ea334f6b..f392dbf05ce 100644 --- a/snippets/csharp/new-in-6/NetworkClient.cs +++ b/snippets/csharp/new-in-6/NetworkClient.cs @@ -27,24 +27,6 @@ public static async Task MakeRequest() } // - // - public static async Task MakeRequestWithNotModifiedSupport() - { - var client = new System.Net.Http.HttpClient(); - var streamTask = client.GetStringAsync("https://localHost:10000"); - try { - var responseText = await streamTask; - return responseText; - } catch (System.Net.Http.HttpRequestException e) when (e.Message.Contains("301")) - { - return "Site Moved"; - } catch (System.Net.Http.HttpRequestException e) when (e.Message.Contains("304")) - { - return "Use the Cache"; - } - } - // - // public static async Task MakeRequestAndLogFailures() { diff --git a/snippets/csharp/new-in-6/Newcode.cs b/snippets/csharp/new-in-6/Newcode.cs index 6ae01daf290..be134971a2a 100644 --- a/snippets/csharp/new-in-6/Newcode.cs +++ b/snippets/csharp/new-in-6/Newcode.cs @@ -34,9 +34,6 @@ public Student(string firstName, string lastName) // public ICollection Grades { get; } = new List(); // - // - public Standing YearInSchool { get; set; } = Standing.Freshman; - // // public string FullName => $"{FirstName} {LastName}"; @@ -46,35 +43,9 @@ public Student(string firstName, string lastName) public override string ToString() => $"{LastName}, {FirstName}"; // - // - public string GetFormattedGradePoint() => - $"Name: {LastName}, {FirstName}. G.P.A: {Grades.Average()}"; - // - // public string GetGradePointPercentage() => $"Name: {LastName}, {FirstName}. G.P.A: {Grades.Average():F2}"; // - - // - public string GetGradePointPercentages() => - $"Name: {LastName}, {FirstName}. G.P.A: {(Grades.Any() ? Grades.Average() : double.NaN):F2}"; - // - - // - public bool MakesDeansList() - { - return Grades.All(g => g > 3.5) && Grades.Any(); - // Code below generates CS0103: - // The name 'All' does not exist in the current context. - //return All(Grades, g => g > 3.5) && Grades.Any(); - } - // - - // - public string GetAllGrades() => - $@"All Grades: {Grades.OrderByDescending(g => g) - .Select(s => s.ToString("F2")).Aggregate((partial, element) => $"{partial}, {element}")}"; - // } } diff --git a/snippets/csharp/new-in-6/Program.cs b/snippets/csharp/new-in-6/Program.cs index 2a198f6c919..8ca441a4864 100644 --- a/snippets/csharp/new-in-6/Program.cs +++ b/snippets/csharp/new-in-6/Program.cs @@ -1,6 +1,5 @@ using System; using System.Runtime.CompilerServices; -using static NewStyle.ExceptionExtensions; namespace NewInCSharp6 { @@ -33,61 +32,8 @@ public static void Main(string[] args) test.Grades.Add(3.5); test.Grades.Add(1.0); test.Grades.Add(1.0); - - Console.WriteLine(test.GetAllGrades()); } - // - public void MethodThatFailsSometimes() - { - try { - PerformFailingOperation(); - } catch (Exception e) when (e.LogException()) - { - // This is never reached! - } - } - // - - // - public void MethodThatFailsButHasRecoveryPath() - { - try { - PerformFailingOperation(); - } catch (Exception e) when (e.LogException()) - { - // This is never reached! - } - catch (RecoverableException ex) - { - Console.WriteLine(ex.ToString()); - // This can still catch the more specific - // exception because the exception filter - // above always returns false. - // Perform recovery here - } - } - // - - // - public void MethodThatFailsWhenDebuggerIsNotAttached() - { - try { - PerformFailingOperation(); - } catch (Exception e) when (e.LogException()) - { - // This is never reached! - } - catch (RecoverableException ex) when (!System.Diagnostics.Debugger.IsAttached) - { - Console.WriteLine(ex.ToString()); - // Only catch exceptions when a debugger is not attached. - // Otherwise, this should stop in the debugger. - } - } - // - - private void PerformFailingOperation() {} } diff --git a/snippets/csharp/new-in-6/classList.cs b/snippets/csharp/new-in-6/classList.cs deleted file mode 100644 index 7dac82dffd9..00000000000 --- a/snippets/csharp/new-in-6/classList.cs +++ /dev/null @@ -1,54 +0,0 @@ -namespace NewStyle -{ - // - public class ClassList - { - public Enrollment CreateEnrollment() - { - // - var classList = new Enrollment() - { - new Student("Lessie", "Crosby"), - new Student("Vicki", "Petty"), - new Student("Ofelia", "Hobbs"), - new Student("Leah", "Kinney"), - new Student("Alton", "Stoker"), - new Student("Luella", "Ferrell"), - new Student("Marcy", "Riggs"), - new Student("Ida", "Bean"), - new Student("Ollie", "Cottle"), - new Student("Tommy", "Broadnax"), - new Student("Jody", "Yates"), - new Student("Marguerite", "Dawson"), - new Student("Francisca", "Barnett"), - new Student("Arlene", "Velasquez"), - new Student("Jodi", "Green"), - new Student("Fran", "Mosley"), - new Student("Taylor", "Nesmith"), - new Student("Ernesto", "Greathouse"), - new Student("Margret", "Albert"), - new Student("Pansy", "House"), - new Student("Sharon", "Byrd"), - new Student("Keith", "Roldan"), - new Student("Martha", "Miranda"), - new Student("Kari", "Campos"), - new Student("Muriel", "Middleton"), - new Student("Georgette", "Jarvis"), - new Student("Pam", "Boyle"), - new Student("Deena", "Travis"), - new Student("Cary", "Totten"), - new Student("Althea", "Goodwin") - }; - // - return classList; - } - } - - // - public static class StudentExtensions - { - public static void Add(this Enrollment e, Student s) => e.Enroll(s); - } - // - // -} \ No newline at end of file diff --git a/wpf/README.md b/wpf/README.md index 204f1d763d2..6b7f72c883d 100644 --- a/wpf/README.md +++ b/wpf/README.md @@ -12,6 +12,9 @@ If you're new to .NET Core, here are a few resources to help you understand the ## Samples in this repo Coming soon! +## Additional Samples +See [WPF Samples](https://www.github.com/Microsoft/wpf-samples) repo for additional WPF samples that have been updated to target .NET Core 3.0. + ## Getting Started ### Prerequisites and getting the tools