diff --git a/csharp/language-reference/operators/Program.cs b/csharp/language-reference/operators/Program.cs
new file mode 100644
index 00000000000..6272c68cd48
--- /dev/null
+++ b/csharp/language-reference/operators/Program.cs
@@ -0,0 +1,14 @@
+using System;
+
+namespace operators
+{
+ class Program
+ {
+ static void Main(string[] args)
+ {
+ Console.WriteLine("============== - operator examples =============");
+ SubtractionOperator.Examples();
+ Console.WriteLine();
+ }
+ }
+}
diff --git a/csharp/language-reference/operators/SubtractionOperator.cs b/csharp/language-reference/operators/SubtractionOperator.cs
new file mode 100644
index 00000000000..3d0892f1a27
--- /dev/null
+++ b/csharp/language-reference/operators/SubtractionOperator.cs
@@ -0,0 +1,58 @@
+using System;
+
+namespace operators
+{
+ public static class SubtractionOperator
+ {
+ public static void Examples()
+ {
+ DelegateRemoval();
+ SubtractAndAssign();
+ }
+
+ private static void DelegateRemoval()
+ {
+ //
+ Action a = () => Console.Write("a");
+ Action b = () => Console.Write("b");
+
+ var abbaab = a + b + b + a + a + b;
+ abbaab(); // output: abbaab
+ Console.WriteLine();
+
+ var ab = a + b;
+ var abba = abbaab - ab;
+ abba(); // output: abba
+ Console.WriteLine();
+
+ var aba = a + b + a;
+ var first = abbaab - aba;
+ first(); // output: abbaab
+ Console.WriteLine();
+
+ var nihil = abbaab - abbaab;
+ Console.WriteLine(nihil is null); // output: True
+ //
+ }
+
+ private static void SubtractAndAssign()
+ {
+ //
+ int i = 5;
+ i -= 9;
+ Console.WriteLine(i);
+ // Output: -4
+
+ Action a = () => Console.Write("a");
+ Action b = () => Console.Write("b");
+ var printer = a + b + a;
+ printer(); // output: aba
+
+ Console.WriteLine();
+ printer -= a;
+ printer(); // output: ab
+ //
+ Console.WriteLine();
+ }
+ }
+}
\ No newline at end of file
diff --git a/csharp/language-reference/operators/operators.csproj b/csharp/language-reference/operators/operators.csproj
new file mode 100644
index 00000000000..05f268b5cc3
--- /dev/null
+++ b/csharp/language-reference/operators/operators.csproj
@@ -0,0 +1,14 @@
+
+
+
+ Exe
+ netcoreapp2.2
+
+
+
+ 7.3
+ operators.Program
+ true
+
+
+
diff --git a/snippets/cpp/VS_Snippets_Data/XmlReader_Validate_SchemaSet/CPP/XmlReader_Validate_SchemaSet.cpp b/snippets/cpp/VS_Snippets_Data/XmlReader_Validate_SchemaSet/CPP/XmlReader_Validate_SchemaSet.cpp
index 3fba401b522..f202c678601 100644
--- a/snippets/cpp/VS_Snippets_Data/XmlReader_Validate_SchemaSet/CPP/XmlReader_Validate_SchemaSet.cpp
+++ b/snippets/cpp/VS_Snippets_Data/XmlReader_Validate_SchemaSet/CPP/XmlReader_Validate_SchemaSet.cpp
@@ -10,7 +10,8 @@ using namespace System::IO;
// Display any validation errors.
static void ValidationCallBack( Object^ /*sender*/, ValidationEventArgs^ e )
{
- Console::WriteLine( L"Validation Error: {0}", e->Message );
+ Console::WriteLine( L"Validation Error:\n {0}", e->Message );
+ Console::WriteLine();
}
int main()
@@ -25,7 +26,7 @@ int main()
XmlReaderSettings^ settings = gcnew XmlReaderSettings;
settings->ValidationType = ValidationType::Schema;
settings->Schemas = sc;
- settings->ValidationEventHandler += gcnew ValidationEventHandler( ValidationCallBack );
+ settings->ValidationEventHandler += gcnew ValidationEventHandler(ValidationCallBack);
// Create the XmlReader object.
XmlReader^ reader = XmlReader::Create( L"booksSchemaFail.xml", settings );
@@ -36,4 +37,14 @@ int main()
return 1;
}
+// The example displays output like the following:
+// Validation Error:
+// The element 'book' in namespace 'urn:bookstore-schema' has invalid child element 'author'
+// in namespace 'urn:bookstore-schema'. List of possible elements expected: 'title' in
+// namespace 'urn:bookstore-schema'.
+//
+// Validation Error:
+// The element 'author' in namespace 'urn:bookstore-schema' has invalid child element 'name'
+// in namespace 'urn:bookstore-schema'. List of possible elements expected: 'first-name' in
+// namespace 'urn:bookstore-schema'.
//
diff --git a/snippets/csharp/VS_Snippets_Data/XmlReader_Validate_SchemaSet/CS/validschemaset.cs b/snippets/csharp/VS_Snippets_Data/XmlReader_Validate_SchemaSet/CS/validschemaset.cs
index 61d211b386a..a08dcbe53fa 100644
--- a/snippets/csharp/VS_Snippets_Data/XmlReader_Validate_SchemaSet/CS/validschemaset.cs
+++ b/snippets/csharp/VS_Snippets_Data/XmlReader_Validate_SchemaSet/CS/validschemaset.cs
@@ -1,11 +1,11 @@
-//
+//
using System;
using System.Xml;
using System.Xml.Schema;
using System.IO;
-public class Sample {
-
+public class Sample
+{
public static void Main() {
// Create the XmlSchemaSet class.
@@ -18,19 +18,28 @@ public static void Main() {
XmlReaderSettings settings = new XmlReaderSettings();
settings.ValidationType = ValidationType.Schema;
settings.Schemas = sc;
- settings.ValidationEventHandler += new ValidationEventHandler (ValidationCallBack);
+ settings.ValidationEventHandler += ValidationCallBack;
// Create the XmlReader object.
XmlReader reader = XmlReader.Create("booksSchemaFail.xml", settings);
// Parse the file.
while (reader.Read());
-
}
// Display any validation errors.
private static void ValidationCallBack(object sender, ValidationEventArgs e) {
- Console.WriteLine("Validation Error: {0}", e.Message);
+ Console.WriteLine($"Validation Error:\n {e.Message}\n");
}
}
-//
\ No newline at end of file
+// The example displays output like the following:
+// Validation Error:
+// The element 'book' in namespace 'urn:bookstore-schema' has invalid child element 'author'
+// in namespace 'urn:bookstore-schema'. List of possible elements expected: 'title' in
+// namespace 'urn:bookstore-schema'.
+//
+// Validation Error:
+// The element 'author' in namespace 'urn:bookstore-schema' has invalid child element 'name'
+// in namespace 'urn:bookstore-schema'. List of possible elements expected: 'first-name' in
+// namespace 'urn:bookstore-schema'.
+//
\ No newline at end of file
diff --git a/snippets/visualbasic/VS_Snippets_Data/XmlReader_Validate_SchemaSet/VB/validschemaset.vb b/snippets/visualbasic/VS_Snippets_Data/XmlReader_Validate_SchemaSet/VB/validschemaset.vb
index 52b3bc8353e..58f308d0094 100644
--- a/snippets/visualbasic/VS_Snippets_Data/XmlReader_Validate_SchemaSet/VB/validschemaset.vb
+++ b/snippets/visualbasic/VS_Snippets_Data/XmlReader_Validate_SchemaSet/VB/validschemaset.vb
@@ -1,12 +1,10 @@
-'
-Imports System
+'
Imports System.Xml
Imports System.Xml.Schema
Imports System.IO
-public class Sample
-
- public shared sub Main()
+Public Module Sample
+ Public Sub Main()
' Create the XmlSchemaSet class.
Dim sc as XmlSchemaSet = new XmlSchemaSet()
@@ -24,14 +22,25 @@ public class Sample
Dim reader as XmlReader = XmlReader.Create("booksSchemaFail.xml", settings)
' Parse the file.
- while reader.Read()
- end while
+ While reader.Read()
+ End While
- end sub
+ End Sub
' Display any validation errors.
- private shared sub ValidationCallBack(sender as object, e as ValidationEventArgs)
- Console.WriteLine("Validation Error: {0}", e.Message)
- end sub
-end class
-'
\ No newline at end of file
+ Private Sub ValidationCallBack(sender as object, e as ValidationEventArgs)
+ Console.WriteLine($"Validation Error:{vbCrLf} {e.Message}")
+ Console.WriteLine()
+ End Sub
+End Module
+' The example displays output like the following:
+' Validation Error:
+' The element 'book' in namespace 'urn:bookstore-schema' has invalid child element 'author'
+' in namespace 'urn:bookstore-schema'. List of possible elements expected: 'title' in
+' namespace 'urn:bookstore-schema'.
+'
+' Validation Error:
+' The element 'author' in namespace 'urn:bookstore-schema' has invalid child element 'name'
+' in namespace 'urn:bookstore-schema'. List of possible elements expected: 'first-name' in
+' namespace 'urn:bookstore-schema'.
+'
\ No newline at end of file