From ba8af359f20dff7eeb2a96143f59ecf5b4c72800 Mon Sep 17 00:00:00 2001 From: Sean Killeen Date: Fri, 5 Apr 2019 10:50:58 -0400 Subject: [PATCH 1/3] Add comment with expected output (#794) --- .../cpp/VS_Snippets_Remoting/NCLUriExamples/CPP/uriexamples.cpp | 1 + .../csharp/VS_Snippets_Remoting/NCLUriExamples/CS/uriexamples.cs | 1 + .../VS_Snippets_Remoting/NCLUriExamples/VB/uriexamples.vb | 1 + 3 files changed, 3 insertions(+) diff --git a/snippets/cpp/VS_Snippets_Remoting/NCLUriExamples/CPP/uriexamples.cpp b/snippets/cpp/VS_Snippets_Remoting/NCLUriExamples/CPP/uriexamples.cpp index 08ee858388b..d92779f548d 100644 --- a/snippets/cpp/VS_Snippets_Remoting/NCLUriExamples/CPP/uriexamples.cpp +++ b/snippets/cpp/VS_Snippets_Remoting/NCLUriExamples/CPP/uriexamples.cpp @@ -67,6 +67,7 @@ namespace Example { Console::WriteLine( "The two addresses are not equal" ); } + // Will output "The two addresses are equal" // } diff --git a/snippets/csharp/VS_Snippets_Remoting/NCLUriExamples/CS/uriexamples.cs b/snippets/csharp/VS_Snippets_Remoting/NCLUriExamples/CS/uriexamples.cs index ea1ccb048aa..4e25f738646 100644 --- a/snippets/csharp/VS_Snippets_Remoting/NCLUriExamples/CS/uriexamples.cs +++ b/snippets/csharp/VS_Snippets_Remoting/NCLUriExamples/CS/uriexamples.cs @@ -65,6 +65,7 @@ private static void SampleEquals() Console.WriteLine("The two addresses are equal"); else Console.WriteLine("The two addresses are not equal"); + // Will output "The two addresses are equal" // } diff --git a/snippets/visualbasic/VS_Snippets_Remoting/NCLUriExamples/VB/uriexamples.vb b/snippets/visualbasic/VS_Snippets_Remoting/NCLUriExamples/VB/uriexamples.vb index 4825ea1341f..97ce22ed94b 100644 --- a/snippets/visualbasic/VS_Snippets_Remoting/NCLUriExamples/VB/uriexamples.vb +++ b/snippets/visualbasic/VS_Snippets_Remoting/NCLUriExamples/VB/uriexamples.vb @@ -62,6 +62,7 @@ Public Class Test Else Console.WriteLine("The two addresses are not equal") End If + ' Will output "The two addresses are equal" ' End Sub 'SampleEquals From 346daa0bbd58d3e9a8e54e48a6b8267e06cf68c2 Mon Sep 17 00:00:00 2001 From: Petr Kulikov Date: Fri, 5 Apr 2019 16:53:58 +0200 Subject: [PATCH 2/3] Added snippets for the logical operators overview (#787) --- .../operators/LogicalOperators.cs | 165 ++++++++++++++++++ .../language-reference/operators/Program.cs | 20 +-- 2 files changed, 173 insertions(+), 12 deletions(-) create mode 100644 snippets/csharp/language-reference/operators/LogicalOperators.cs diff --git a/snippets/csharp/language-reference/operators/LogicalOperators.cs b/snippets/csharp/language-reference/operators/LogicalOperators.cs new file mode 100644 index 00000000000..50af37e9054 --- /dev/null +++ b/snippets/csharp/language-reference/operators/LogicalOperators.cs @@ -0,0 +1,165 @@ +using System; + +namespace operators +{ + public static class LogicalOperators + { + public static void Examples() + { + Console.WriteLine("==== ! operator"); + Negation(); + + Console.WriteLine("==== &, |, ^ operators"); + And(); + Or(); + Xor(); + + Console.WriteLine("==== && and || operators"); + ConditionalAnd(); + ConditionalOr(); + + Console.WriteLine("==== Compound assignment and precedence"); + CompoundAssignment(); + Precedence(); + } + + private static void Negation() + { + // + bool passed = false; + Console.WriteLine(!passed); // output: True + Console.WriteLine(!true); // output: False + // + } + + private static void And() + { + // + bool SecondOperand() + { + Console.WriteLine("Second operand is evaluated."); + return true; + } + + bool test = false & SecondOperand(); + Console.WriteLine(test); + // Output: + // Second operand is evaluated. + // False + // + } + + private static void Or() + { + // + bool SecondOperand() + { + Console.WriteLine("Second operand is evaluated."); + return false; + } + + bool test = true | SecondOperand(); + Console.WriteLine(test); + // Output: + // Second operand is evaluated. + // True + // + } + + private static void Xor() + { + // + Console.WriteLine(true ^ true); // output: False + Console.WriteLine(true ^ false); // output: True + Console.WriteLine(false ^ true); // output: True + Console.WriteLine(false ^ false); // output: False + // + } + + private static void ConditionalAnd() + { + // + bool SecondOperand() + { + Console.WriteLine("Second operand is evaluated."); + return true; + } + + bool a = false && SecondOperand(); + Console.WriteLine(a); + // Output: + // False + + bool b = true && SecondOperand(); + Console.WriteLine(b); + // Output: + // Second operand is evaluated. + // True + // + } + + private static void ConditionalOr() + { + // + bool SecondOperand() + { + Console.WriteLine("Second operand is evaluated."); + return true; + } + + bool a = true || SecondOperand(); + Console.WriteLine(a); + // Output: + // True + + bool b = false || SecondOperand(); + Console.WriteLine(b); + // Output: + // Second operand is evaluated. + // True + // + } + + private static void CompoundAssignment() + { + // + bool test = true; + test &= false; + Console.WriteLine(test); // output: False + + test |= true; + Console.WriteLine(test); // output: True + + test ^= false; + Console.WriteLine(test); // output: True + // + } + + private static void Precedence() + { + // + Console.WriteLine(true | true & false); // output: True + Console.WriteLine((true | true) & false); // output: False + + bool Operand(string name, bool value) + { + Console.WriteLine($"Operand {name} is evaluated."); + return value; + } + + var byDefaultPrecedence = Operand("A", true) || Operand("B", true) && Operand("C", false); + Console.WriteLine(byDefaultPrecedence); + // Output: + // Operand A is evaluated. + // True + + var changedOrder = (Operand("A", true) || Operand("B", true)) && Operand("C", false); + Console.WriteLine(changedOrder); + // Output: + // Operand A is evaluated. + // Operand C is evaluated. + // False + // + } + } +} \ No newline at end of file diff --git a/snippets/csharp/language-reference/operators/Program.cs b/snippets/csharp/language-reference/operators/Program.cs index db0030b3ffe..2df40e6eebb 100644 --- a/snippets/csharp/language-reference/operators/Program.cs +++ b/snippets/csharp/language-reference/operators/Program.cs @@ -10,6 +10,14 @@ static void Main(string[] args) ArithmeticOperators.Examples(); Console.WriteLine(); + Console.WriteLine("============== == and != operator examples ====="); + EqualityAndNonEqualityExamples.Examples(); + Console.WriteLine(); + + Console.WriteLine("======== Logical operators examples ============"); + LogicalOperators.Examples(); + Console.WriteLine(); + Console.WriteLine("============== + operator examples ============="); AdditionExamples.Examples(); Console.WriteLine(); @@ -30,14 +38,6 @@ static void Main(string[] args) BitwiseComplementExamples.Examples(); Console.WriteLine(); - Console.WriteLine("============== && and || operator examples ====="); - ConditionalLogicalOperatorsExamples.Examples(); - Console.WriteLine(); - - Console.WriteLine("============== == and != operator examples ====="); - EqualityAndNonEqualityExamples.Examples(); - Console.WriteLine(); - Console.WriteLine("======= >, <, >=, and <= operator examples ====="); GreaterAndLessOperatorsExamples.Examples(); Console.WriteLine(); @@ -58,10 +58,6 @@ static void Main(string[] args) ShiftOperatorsExamples.Examples(); Console.WriteLine(); - Console.WriteLine("============== ! operator examples ============="); - LogicalNegationExamples.Examples(); - Console.WriteLine(); - Console.WriteLine("============== . operator examples ============="); MemberAccessExamples.Examples(); Console.WriteLine(); From 0885263416650a4b79b4b16673b45ea8d714a4a7 Mon Sep 17 00:00:00 2001 From: Maira Wenzel Date: Fri, 5 Apr 2019 17:56:54 -0700 Subject: [PATCH 3/3] add the other repo to the description (#792) --- .github/PULL_REQUEST_TEMPLATE.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index 5ce02cefa67..1ace3f6f925 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -2,4 +2,4 @@ Describe your changes here. -Fixes dotnet/docs#Issue_Number (if available) +Fixes dotnet/docs#Issue_Number or dotnet/dotnet-api-docs#Issue_Number (if available)