diff --git a/.gitignore b/.gitignore
index 0b800534620..25d00d97aa9 100644
--- a/.gitignore
+++ b/.gitignore
@@ -211,7 +211,7 @@ samples/WebApplication1/src/WebApplication1/wwwroot/lib/
_site/
api_src/
-api/
+/api/
_themes/
_themes.pdf/
_csharplang/
diff --git a/README.md b/README.md
index afa4d0eeb61..ea32459070e 100644
--- a/README.md
+++ b/README.md
@@ -3,6 +3,6 @@
This repo contains documentation for the .NET API Reference.
The main repository for .NET documentation is the [.NET Docs repository](https://github.com/dotnet/docs). See the [Contributing Guide](https://github.com/dotnet/docs/blob/master/CONTRIBUTING.md) for information on updating .NET API reference documentation.
-We are tracking all work for this repository using [GitHub issues](https://github.com/dotnet/dotnet-api-docs/issues). The documentation for APIs is built from the text in this repo, and the samples in the [dotnet/samples](https://github.com/dotnet/samples) repository. You can select the [Repo - samples](https://github.com/dotnet/docs/issues?q=is%3Aopen+is%3Aissue+label%3A%22%3Afile_folder%3A+Repo+-+samples%22) label to see issues that concern sample code.
+We're tracking all work for this repository using [GitHub issues](https://github.com/dotnet/dotnet-api-docs/issues). The documentation for APIs is built from the text in this repo, and the samples in the [dotnet/samples](https://github.com/dotnet/samples) repository. You can select the [Repo - samples](https://github.com/dotnet/docs/issues?q=is%3Aopen+is%3Aissue+label%3A%22%3Afile_folder%3A+Repo+-+samples%22) label to see issues that concern sample code.
This project has adopted the code of conduct defined by the Contributor Covenant to clarify expected behavior in our community. For more information, see the [.NET Foundation Code of Conduct](https://dotnetfoundation.org/code-of-conduct).
diff --git a/samples/snippets/cpp/VS_Snippets_CLR_System/system.Char [Type Level]/CPP/charstructure.cpp b/samples/snippets/cpp/VS_Snippets_CLR_System/system.Char [Type Level]/CPP/charstructure.cpp
new file mode 100644
index 00000000000..d8f643f6d5a
--- /dev/null
+++ b/samples/snippets/cpp/VS_Snippets_CLR_System/system.Char [Type Level]/CPP/charstructure.cpp
@@ -0,0 +1,26 @@
+
+//
+using namespace System;
+int main()
+{
+ char chA = 'A';
+ char ch1 = '1';
+ String^ str = "test string";
+ Console::WriteLine( chA.CompareTo( 'B' ) ); // Output: "-1" (meaning 'A' is 1 less than 'B')
+ Console::WriteLine( chA.Equals( 'A' ) ); // Output: "True"
+ Console::WriteLine( Char::GetNumericValue( ch1 ) ); // Output: "1"
+ Console::WriteLine( Char::IsControl( '\t' ) ); // Output: "True"
+ Console::WriteLine( Char::IsDigit( ch1 ) ); // Output: "True"
+ Console::WriteLine( Char::IsLetter( ',' ) ); // Output: "False"
+ Console::WriteLine( Char::IsLower( 'u' ) ); // Output: "True"
+ Console::WriteLine( Char::IsNumber( ch1 ) ); // Output: "True"
+ Console::WriteLine( Char::IsPunctuation( '.' ) ); // Output: "True"
+ Console::WriteLine( Char::IsSeparator( str, 4 ) ); // Output: "True"
+ Console::WriteLine( Char::IsSymbol( '+' ) ); // Output: "True"
+ Console::WriteLine( Char::IsWhiteSpace( str, 4 ) ); // Output: "True"
+ Console::WriteLine( Char::Parse( "S" ) ); // Output: "S"
+ Console::WriteLine( Char::ToLower( 'M' ) ); // Output: "m"
+ Console::WriteLine( 'x' ); // Output: "x"
+}
+
+//
diff --git a/samples/snippets/csharp/VS_Snippets_Atlas/System.Web.Script.Serialization.TypeResolver/CS/Default.aspx b/samples/snippets/csharp/VS_Snippets_Atlas/System.Web.Script.Serialization.TypeResolver/CS/Default.aspx
new file mode 100644
index 00000000000..971e38ba264
--- /dev/null
+++ b/samples/snippets/csharp/VS_Snippets_Atlas/System.Web.Script.Serialization.TypeResolver/CS/Default.aspx
@@ -0,0 +1,70 @@
+
+<%@ Page Language="C#" %>
+<%@ Import Namespace="System.Web.Script.Serialization" %>
+<%@ Import Namespace="System.Web.Script.Serialization.TypeResolver.CS" %>
+
+
+
+
+
+
+
+ Type Resolvers
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/samples/snippets/csharp/VS_Snippets_Atlas/System.Web.Script.Serialization/CS/Default.aspx b/samples/snippets/csharp/VS_Snippets_Atlas/System.Web.Script.Serialization/CS/Default.aspx
new file mode 100644
index 00000000000..d3b3f0f821d
--- /dev/null
+++ b/samples/snippets/csharp/VS_Snippets_Atlas/System.Web.Script.Serialization/CS/Default.aspx
@@ -0,0 +1,180 @@
+
+<%@ Page Language="C#" %>
+<%@ Import Namespace="System.Web.Script.Serialization" %>
+
+
+
+
+
+
+
+ Save/Recover state
+
+
+
+
+
+
+
diff --git a/samples/snippets/csharp/VS_Snippets_Atlas/System.Web.UI.UpdatePanel.CreateContentTemplateContainer/CS/UpdatePanelCreateContentTemplateContainerCS.aspx b/samples/snippets/csharp/VS_Snippets_Atlas/System.Web.UI.UpdatePanel.CreateContentTemplateContainer/CS/UpdatePanelCreateContentTemplateContainerCS.aspx
new file mode 100644
index 00000000000..b5f946fabd7
--- /dev/null
+++ b/samples/snippets/csharp/VS_Snippets_Atlas/System.Web.UI.UpdatePanel.CreateContentTemplateContainer/CS/UpdatePanelCreateContentTemplateContainerCS.aspx
@@ -0,0 +1,29 @@
+
+<%@ Page Language="C#" %>
+<%@ Register Namespace="SamplesCS" TagPrefix="Samples" %>
+
+
+
+
+ CreateContentTemplateContainer Example
+
+
+
+
+
+
diff --git a/samples/snippets/csharp/VS_Snippets_CLR_System/system.Char [Type Level]/CS/charstructure.cs b/samples/snippets/csharp/VS_Snippets_CLR_System/system.Char [Type Level]/CS/charstructure.cs
new file mode 100644
index 00000000000..4999052da6c
--- /dev/null
+++ b/samples/snippets/csharp/VS_Snippets_CLR_System/system.Char [Type Level]/CS/charstructure.cs
@@ -0,0 +1,29 @@
+//
+using System;
+
+public class CharStructureSample
+{
+ public static void Main()
+ {
+ char chA = 'A';
+ char ch1 = '1';
+ string str = "test string";
+
+ Console.WriteLine(chA.CompareTo('B')); //----------- Output: "-1" (meaning 'A' is 1 less than 'B')
+ Console.WriteLine(chA.Equals('A')); //----------- Output: "True"
+ Console.WriteLine(Char.GetNumericValue(ch1)); //----------- Output: "1"
+ Console.WriteLine(Char.IsControl('\t')); //----------- Output: "True"
+ Console.WriteLine(Char.IsDigit(ch1)); //----------- Output: "True"
+ Console.WriteLine(Char.IsLetter(',')); //----------- Output: "False"
+ Console.WriteLine(Char.IsLower('u')); //----------- Output: "True"
+ Console.WriteLine(Char.IsNumber(ch1)); //----------- Output: "True"
+ Console.WriteLine(Char.IsPunctuation('.')); //----------- Output: "True"
+ Console.WriteLine(Char.IsSeparator(str, 4)); //----------- Output: "True"
+ Console.WriteLine(Char.IsSymbol('+')); //----------- Output: "True"
+ Console.WriteLine(Char.IsWhiteSpace(str, 4)); //----------- Output: "True"
+ Console.WriteLine(Char.Parse("S")); //----------- Output: "S"
+ Console.WriteLine(Char.ToLower('M')); //----------- Output: "m"
+ Console.WriteLine('x'.ToString()); //----------- Output: "x"
+ }
+}
+//
diff --git a/samples/snippets/csharp/VS_Snippets_CLR_System/system.Collections.ArrayList.ToArray/CS/arraylist_toarray.cs b/samples/snippets/csharp/VS_Snippets_CLR_System/system.Collections.ArrayList.ToArray/CS/arraylist_toarray.cs
new file mode 100644
index 00000000000..28c23b35e13
--- /dev/null
+++ b/samples/snippets/csharp/VS_Snippets_CLR_System/system.Collections.ArrayList.ToArray/CS/arraylist_toarray.cs
@@ -0,0 +1,77 @@
+// The following example shows how to copy the elements of an ArrayList to a string array.
+
+//
+using System;
+using System.Collections;
+
+public class SamplesArrayList {
+
+ public static void Main() {
+
+ // Creates and initializes a new ArrayList.
+ ArrayList myAL = new ArrayList();
+ myAL.Add( "The" );
+ myAL.Add( "quick" );
+ myAL.Add( "brown" );
+ myAL.Add( "fox" );
+ myAL.Add( "jumps" );
+ myAL.Add( "over" );
+ myAL.Add( "the" );
+ myAL.Add( "lazy" );
+ myAL.Add( "dog" );
+
+ // Displays the values of the ArrayList.
+ Console.WriteLine( "The ArrayList contains the following values:" );
+ PrintIndexAndValues( myAL );
+
+ // Copies the elements of the ArrayList to a string array.
+ String[] myArr = (String[]) myAL.ToArray( typeof( string ) );
+
+ // Displays the contents of the string array.
+ Console.WriteLine( "The string array contains the following values:" );
+ PrintIndexAndValues( myArr );
+ }
+
+ public static void PrintIndexAndValues( ArrayList myList ) {
+ int i = 0;
+ foreach ( Object o in myList )
+ Console.WriteLine( "\t[{0}]:\t{1}", i++, o );
+ Console.WriteLine();
+ }
+
+ public static void PrintIndexAndValues( String[] myArr ) {
+ for ( int i = 0; i < myArr.Length; i++ )
+ Console.WriteLine( "\t[{0}]:\t{1}", i, myArr[i] );
+ Console.WriteLine();
+ }
+}
+
+
+/*
+This code produces the following output.
+
+The ArrayList contains the following values:
+ [0]: The
+ [1]: quick
+ [2]: brown
+ [3]: fox
+ [4]: jumps
+ [5]: over
+ [6]: the
+ [7]: lazy
+ [8]: dog
+
+The string array contains the following values:
+ [0]: The
+ [1]: quick
+ [2]: brown
+ [3]: fox
+ [4]: jumps
+ [5]: over
+ [6]: the
+ [7]: lazy
+ [8]: dog
+
+*/
+
+//
diff --git a/samples/snippets/csharp/VS_Snippets_Wpf/DocumentStructure/CSharp/App.xaml b/samples/snippets/csharp/VS_Snippets_Wpf/DocumentStructure/CSharp/App.xaml
new file mode 100644
index 00000000000..5902862c067
--- /dev/null
+++ b/samples/snippets/csharp/VS_Snippets_Wpf/DocumentStructure/CSharp/App.xaml
@@ -0,0 +1,9 @@
+
+
+
+
+
+
diff --git a/samples/snippets/csharp/VS_Snippets_Wpf/DocumentStructure/CSharp/App.xaml.cs b/samples/snippets/csharp/VS_Snippets_Wpf/DocumentStructure/CSharp/App.xaml.cs
new file mode 100644
index 00000000000..f3ffa29e8a4
--- /dev/null
+++ b/samples/snippets/csharp/VS_Snippets_Wpf/DocumentStructure/CSharp/App.xaml.cs
@@ -0,0 +1,24 @@
+// DocumentStructure SDK Sample - App.xaml.cs
+// Copyright (c) Microsoft Corporation. All rights reserved.
+
+using System;
+using System.Windows;
+using System.Data;
+using System.Xml;
+using System.Configuration;
+using System.Windows.Input;
+using System.Windows.Media;
+
+namespace SdkSample
+{
+ ///
+ /// Interaction logic for App.xaml
+ public partial class App : Application
+ {
+ void AppStartingUp(object sender, StartupEventArgs e)
+ {
+ Window1 mainWindow = new Window1();
+ mainWindow.Show();
+ }
+ }
+}
\ No newline at end of file
diff --git a/samples/snippets/csharp/VS_Snippets_Wpf/DocumentStructure/CSharp/DocumentStructure.csproj b/samples/snippets/csharp/VS_Snippets_Wpf/DocumentStructure/CSharp/DocumentStructure.csproj
new file mode 100644
index 00000000000..a1406e1c66b
--- /dev/null
+++ b/samples/snippets/csharp/VS_Snippets_Wpf/DocumentStructure/CSharp/DocumentStructure.csproj
@@ -0,0 +1,73 @@
+
+
+ Debug
+ AnyCPU
+ {0DA25C02-0A70-4246-8DEE-0570A8FF1668}
+ SdkSample
+ DocumentStructure
+ 4
+ winexe
+ $(OutputType)
+ 1.0.0.*
+ {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}
+ v4.0
+ Client
+ 10.0.20821
+
+
+ true
+ full
+ false
+
+ .\bin\Debug\
+ DEBUG;TRACE
+
+
+ false
+ true
+
+ .\bin\Release\
+ TRACE
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 4.0
+
+
+
+
+
+ MSBuild:Compile
+ Designer
+
+
+ MSBuild:Compile
+ Designer
+
+
+ App.xaml
+ Code
+
+
+ Window1.xaml
+ Code
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/samples/snippets/csharp/VS_Snippets_Wpf/DocumentStructure/CSharp/Spec_withStructure-xps/Documents/0/Structure/Fragments/1.frag b/samples/snippets/csharp/VS_Snippets_Wpf/DocumentStructure/CSharp/Spec_withStructure-xps/Documents/0/Structure/Fragments/1.frag
new file mode 100644
index 00000000000..e286f4e516f
--- /dev/null
+++ b/samples/snippets/csharp/VS_Snippets_Wpf/DocumentStructure/CSharp/Spec_withStructure-xps/Documents/0/Structure/Fragments/1.frag
@@ -0,0 +1,135 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/samples/snippets/csharp/VS_Snippets_Wpf/DocumentStructure/CSharp/Spec_withStructure-xps/Documents/0/Structure/Fragments/2.frag b/samples/snippets/csharp/VS_Snippets_Wpf/DocumentStructure/CSharp/Spec_withStructure-xps/Documents/0/Structure/Fragments/2.frag
new file mode 100644
index 00000000000..5817b750cad
--- /dev/null
+++ b/samples/snippets/csharp/VS_Snippets_Wpf/DocumentStructure/CSharp/Spec_withStructure-xps/Documents/0/Structure/Fragments/2.frag
@@ -0,0 +1,149 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/samples/snippets/csharp/VS_Snippets_Wpf/DocumentStructure/CSharp/Spec_withStructure-xps/Documents/FixedDocument_1.fdoc b/samples/snippets/csharp/VS_Snippets_Wpf/DocumentStructure/CSharp/Spec_withStructure-xps/Documents/FixedDocument_1.fdoc
new file mode 100644
index 00000000000..69339963593
--- /dev/null
+++ b/samples/snippets/csharp/VS_Snippets_Wpf/DocumentStructure/CSharp/Spec_withStructure-xps/Documents/FixedDocument_1.fdoc
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/samples/snippets/csharp/VS_Snippets_Wpf/DocumentStructure/CSharp/Spec_withStructure-xps/FixedDocumentSequence.fdseq b/samples/snippets/csharp/VS_Snippets_Wpf/DocumentStructure/CSharp/Spec_withStructure-xps/FixedDocumentSequence.fdseq
new file mode 100644
index 00000000000..abe5cea3a84
--- /dev/null
+++ b/samples/snippets/csharp/VS_Snippets_Wpf/DocumentStructure/CSharp/Spec_withStructure-xps/FixedDocumentSequence.fdseq
@@ -0,0 +1,3 @@
+
+
+
diff --git a/samples/snippets/csharp/VS_Snippets_Wpf/DocumentStructure/CSharp/Spec_withStructure-xps/Pages/FixedPage_1.fpage b/samples/snippets/csharp/VS_Snippets_Wpf/DocumentStructure/CSharp/Spec_withStructure-xps/Pages/FixedPage_1.fpage
new file mode 100644
index 00000000000..308dc0f9caa
--- /dev/null
+++ b/samples/snippets/csharp/VS_Snippets_Wpf/DocumentStructure/CSharp/Spec_withStructure-xps/Pages/FixedPage_1.fpage
@@ -0,0 +1,482 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/samples/snippets/csharp/VS_Snippets_Wpf/DocumentStructure/CSharp/Spec_withStructure-xps/Pages/FixedPage_2.fpage b/samples/snippets/csharp/VS_Snippets_Wpf/DocumentStructure/CSharp/Spec_withStructure-xps/Pages/FixedPage_2.fpage
new file mode 100644
index 00000000000..009c1c674eb
--- /dev/null
+++ b/samples/snippets/csharp/VS_Snippets_Wpf/DocumentStructure/CSharp/Spec_withStructure-xps/Pages/FixedPage_2.fpage
@@ -0,0 +1,602 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/samples/snippets/csharp/VS_Snippets_Wpf/DocumentStructure/CSharp/Spec_withStructure-xps/Pages/_rels/FixedPage_1.fpage.rels b/samples/snippets/csharp/VS_Snippets_Wpf/DocumentStructure/CSharp/Spec_withStructure-xps/Pages/_rels/FixedPage_1.fpage.rels
new file mode 100644
index 00000000000..3be7c594ef4
--- /dev/null
+++ b/samples/snippets/csharp/VS_Snippets_Wpf/DocumentStructure/CSharp/Spec_withStructure-xps/Pages/_rels/FixedPage_1.fpage.rels
@@ -0,0 +1,21 @@
+
+
+
+
+
+
+
+
+
diff --git a/samples/snippets/csharp/VS_Snippets_Wpf/DocumentStructure/CSharp/Spec_withStructure-xps/Pages/_rels/FixedPage_2.fpage.rels b/samples/snippets/csharp/VS_Snippets_Wpf/DocumentStructure/CSharp/Spec_withStructure-xps/Pages/_rels/FixedPage_2.fpage.rels
new file mode 100644
index 00000000000..c2c1eec5836
--- /dev/null
+++ b/samples/snippets/csharp/VS_Snippets_Wpf/DocumentStructure/CSharp/Spec_withStructure-xps/Pages/_rels/FixedPage_2.fpage.rels
@@ -0,0 +1,31 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/samples/snippets/csharp/VS_Snippets_Wpf/DocumentStructure/CSharp/Spec_withStructure-xps/Resources/Fonts/33c063c8-1259-4322-acc8-8fc1964cc064.ODTTF b/samples/snippets/csharp/VS_Snippets_Wpf/DocumentStructure/CSharp/Spec_withStructure-xps/Resources/Fonts/33c063c8-1259-4322-acc8-8fc1964cc064.ODTTF
new file mode 100644
index 00000000000..c8cc8c5af00
Binary files /dev/null and b/samples/snippets/csharp/VS_Snippets_Wpf/DocumentStructure/CSharp/Spec_withStructure-xps/Resources/Fonts/33c063c8-1259-4322-acc8-8fc1964cc064.ODTTF differ
diff --git a/samples/snippets/csharp/VS_Snippets_Wpf/DocumentStructure/CSharp/Spec_withStructure-xps/Resources/Fonts/3b85141b-0969-4d9e-b9c8-e705bb7e6543.ODTTF b/samples/snippets/csharp/VS_Snippets_Wpf/DocumentStructure/CSharp/Spec_withStructure-xps/Resources/Fonts/3b85141b-0969-4d9e-b9c8-e705bb7e6543.ODTTF
new file mode 100644
index 00000000000..d8d0696e90c
Binary files /dev/null and b/samples/snippets/csharp/VS_Snippets_Wpf/DocumentStructure/CSharp/Spec_withStructure-xps/Resources/Fonts/3b85141b-0969-4d9e-b9c8-e705bb7e6543.ODTTF differ
diff --git a/samples/snippets/csharp/VS_Snippets_Wpf/DocumentStructure/CSharp/Spec_withStructure-xps/Resources/Fonts/3f87ce81-fb61-4ea7-8d62-aed569d1b895.ODTTF b/samples/snippets/csharp/VS_Snippets_Wpf/DocumentStructure/CSharp/Spec_withStructure-xps/Resources/Fonts/3f87ce81-fb61-4ea7-8d62-aed569d1b895.ODTTF
new file mode 100644
index 00000000000..a64452baba6
Binary files /dev/null and b/samples/snippets/csharp/VS_Snippets_Wpf/DocumentStructure/CSharp/Spec_withStructure-xps/Resources/Fonts/3f87ce81-fb61-4ea7-8d62-aed569d1b895.ODTTF differ
diff --git a/samples/snippets/csharp/VS_Snippets_Wpf/DocumentStructure/CSharp/Spec_withStructure-xps/Resources/Fonts/64326a24-1829-4393-8602-67e5b520db43.ODTTF b/samples/snippets/csharp/VS_Snippets_Wpf/DocumentStructure/CSharp/Spec_withStructure-xps/Resources/Fonts/64326a24-1829-4393-8602-67e5b520db43.ODTTF
new file mode 100644
index 00000000000..a026d3b90d3
Binary files /dev/null and b/samples/snippets/csharp/VS_Snippets_Wpf/DocumentStructure/CSharp/Spec_withStructure-xps/Resources/Fonts/64326a24-1829-4393-8602-67e5b520db43.ODTTF differ
diff --git a/samples/snippets/csharp/VS_Snippets_Wpf/DocumentStructure/CSharp/Spec_withStructure-xps/Resources/Fonts/9aa4ea89-755c-4331-be84-0cd43ff87195.ODTTF b/samples/snippets/csharp/VS_Snippets_Wpf/DocumentStructure/CSharp/Spec_withStructure-xps/Resources/Fonts/9aa4ea89-755c-4331-be84-0cd43ff87195.ODTTF
new file mode 100644
index 00000000000..59e15b9567d
Binary files /dev/null and b/samples/snippets/csharp/VS_Snippets_Wpf/DocumentStructure/CSharp/Spec_withStructure-xps/Resources/Fonts/9aa4ea89-755c-4331-be84-0cd43ff87195.ODTTF differ
diff --git a/samples/snippets/csharp/VS_Snippets_Wpf/DocumentStructure/CSharp/Spec_withStructure-xps/Resources/Images/Image_1.png b/samples/snippets/csharp/VS_Snippets_Wpf/DocumentStructure/CSharp/Spec_withStructure-xps/Resources/Images/Image_1.png
new file mode 100644
index 00000000000..f794f2e524b
Binary files /dev/null and b/samples/snippets/csharp/VS_Snippets_Wpf/DocumentStructure/CSharp/Spec_withStructure-xps/Resources/Images/Image_1.png differ
diff --git a/samples/snippets/csharp/VS_Snippets_Wpf/DocumentStructure/CSharp/Spec_withStructure-xps/Resources/Images/Image_2.png b/samples/snippets/csharp/VS_Snippets_Wpf/DocumentStructure/CSharp/Spec_withStructure-xps/Resources/Images/Image_2.png
new file mode 100644
index 00000000000..23925f0b825
Binary files /dev/null and b/samples/snippets/csharp/VS_Snippets_Wpf/DocumentStructure/CSharp/Spec_withStructure-xps/Resources/Images/Image_2.png differ
diff --git a/samples/snippets/csharp/VS_Snippets_Wpf/DocumentStructure/CSharp/Spec_withStructure-xps/Resources/Images/Image_3.png b/samples/snippets/csharp/VS_Snippets_Wpf/DocumentStructure/CSharp/Spec_withStructure-xps/Resources/Images/Image_3.png
new file mode 100644
index 00000000000..31029e93643
Binary files /dev/null and b/samples/snippets/csharp/VS_Snippets_Wpf/DocumentStructure/CSharp/Spec_withStructure-xps/Resources/Images/Image_3.png differ
diff --git a/samples/snippets/csharp/VS_Snippets_Wpf/DocumentStructure/CSharp/Spec_withStructure-xps/Resources/Images/Image_4.png b/samples/snippets/csharp/VS_Snippets_Wpf/DocumentStructure/CSharp/Spec_withStructure-xps/Resources/Images/Image_4.png
new file mode 100644
index 00000000000..29da46a89ec
Binary files /dev/null and b/samples/snippets/csharp/VS_Snippets_Wpf/DocumentStructure/CSharp/Spec_withStructure-xps/Resources/Images/Image_4.png differ
diff --git a/samples/snippets/csharp/VS_Snippets_Wpf/DocumentStructure/CSharp/Spec_withStructure-xps/Resources/Images/Image_5.png b/samples/snippets/csharp/VS_Snippets_Wpf/DocumentStructure/CSharp/Spec_withStructure-xps/Resources/Images/Image_5.png
new file mode 100644
index 00000000000..70e57c28ddb
Binary files /dev/null and b/samples/snippets/csharp/VS_Snippets_Wpf/DocumentStructure/CSharp/Spec_withStructure-xps/Resources/Images/Image_5.png differ
diff --git a/samples/snippets/csharp/VS_Snippets_Wpf/DocumentStructure/CSharp/Spec_withStructure-xps/[Content_Types].xml b/samples/snippets/csharp/VS_Snippets_Wpf/DocumentStructure/CSharp/Spec_withStructure-xps/[Content_Types].xml
new file mode 100644
index 00000000000..89be2f9bd2c
--- /dev/null
+++ b/samples/snippets/csharp/VS_Snippets_Wpf/DocumentStructure/CSharp/Spec_withStructure-xps/[Content_Types].xml
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/samples/snippets/csharp/VS_Snippets_Wpf/DocumentStructure/CSharp/Spec_withStructure-xps/_rels/.rels b/samples/snippets/csharp/VS_Snippets_Wpf/DocumentStructure/CSharp/Spec_withStructure-xps/_rels/.rels
new file mode 100644
index 00000000000..b418a20901b
--- /dev/null
+++ b/samples/snippets/csharp/VS_Snippets_Wpf/DocumentStructure/CSharp/Spec_withStructure-xps/_rels/.rels
@@ -0,0 +1,5 @@
+
+
+
+
\ No newline at end of file
diff --git a/samples/snippets/csharp/VS_Snippets_Wpf/DocumentStructure/CSharp/Spec_withoutStructure-xps/Documents/FixedDocument_1.fdoc b/samples/snippets/csharp/VS_Snippets_Wpf/DocumentStructure/CSharp/Spec_withoutStructure-xps/Documents/FixedDocument_1.fdoc
new file mode 100644
index 00000000000..05fa57b183d
--- /dev/null
+++ b/samples/snippets/csharp/VS_Snippets_Wpf/DocumentStructure/CSharp/Spec_withoutStructure-xps/Documents/FixedDocument_1.fdoc
@@ -0,0 +1,4 @@
+
+
+
+
\ No newline at end of file
diff --git a/samples/snippets/csharp/VS_Snippets_Wpf/DocumentStructure/CSharp/Spec_withoutStructure-xps/FixedDocumentSequence.fdseq b/samples/snippets/csharp/VS_Snippets_Wpf/DocumentStructure/CSharp/Spec_withoutStructure-xps/FixedDocumentSequence.fdseq
new file mode 100644
index 00000000000..48debadd931
--- /dev/null
+++ b/samples/snippets/csharp/VS_Snippets_Wpf/DocumentStructure/CSharp/Spec_withoutStructure-xps/FixedDocumentSequence.fdseq
@@ -0,0 +1,3 @@
+
+
+
\ No newline at end of file
diff --git a/samples/snippets/csharp/VS_Snippets_Wpf/DocumentStructure/CSharp/Spec_withoutStructure-xps/Pages/FixedPage_1.fpage b/samples/snippets/csharp/VS_Snippets_Wpf/DocumentStructure/CSharp/Spec_withoutStructure-xps/Pages/FixedPage_1.fpage
new file mode 100644
index 00000000000..308dc0f9caa
--- /dev/null
+++ b/samples/snippets/csharp/VS_Snippets_Wpf/DocumentStructure/CSharp/Spec_withoutStructure-xps/Pages/FixedPage_1.fpage
@@ -0,0 +1,482 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/samples/snippets/csharp/VS_Snippets_Wpf/DocumentStructure/CSharp/Spec_withoutStructure-xps/Pages/FixedPage_2.fpage b/samples/snippets/csharp/VS_Snippets_Wpf/DocumentStructure/CSharp/Spec_withoutStructure-xps/Pages/FixedPage_2.fpage
new file mode 100644
index 00000000000..009c1c674eb
--- /dev/null
+++ b/samples/snippets/csharp/VS_Snippets_Wpf/DocumentStructure/CSharp/Spec_withoutStructure-xps/Pages/FixedPage_2.fpage
@@ -0,0 +1,602 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/samples/snippets/csharp/VS_Snippets_Wpf/DocumentStructure/CSharp/Spec_withoutStructure-xps/Pages/_rels/FixedPage_1.fpage.rels b/samples/snippets/csharp/VS_Snippets_Wpf/DocumentStructure/CSharp/Spec_withoutStructure-xps/Pages/_rels/FixedPage_1.fpage.rels
new file mode 100644
index 00000000000..b0f029c494a
--- /dev/null
+++ b/samples/snippets/csharp/VS_Snippets_Wpf/DocumentStructure/CSharp/Spec_withoutStructure-xps/Pages/_rels/FixedPage_1.fpage.rels
@@ -0,0 +1,18 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/samples/snippets/csharp/VS_Snippets_Wpf/DocumentStructure/CSharp/Spec_withoutStructure-xps/Pages/_rels/FixedPage_2.fpage.rels b/samples/snippets/csharp/VS_Snippets_Wpf/DocumentStructure/CSharp/Spec_withoutStructure-xps/Pages/_rels/FixedPage_2.fpage.rels
new file mode 100644
index 00000000000..34c682534b7
--- /dev/null
+++ b/samples/snippets/csharp/VS_Snippets_Wpf/DocumentStructure/CSharp/Spec_withoutStructure-xps/Pages/_rels/FixedPage_2.fpage.rels
@@ -0,0 +1,28 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/samples/snippets/csharp/VS_Snippets_Wpf/DocumentStructure/CSharp/Spec_withoutStructure-xps/Resources/Fonts/33c063c8-1259-4322-acc8-8fc1964cc064.ODTTF b/samples/snippets/csharp/VS_Snippets_Wpf/DocumentStructure/CSharp/Spec_withoutStructure-xps/Resources/Fonts/33c063c8-1259-4322-acc8-8fc1964cc064.ODTTF
new file mode 100644
index 00000000000..c8cc8c5af00
Binary files /dev/null and b/samples/snippets/csharp/VS_Snippets_Wpf/DocumentStructure/CSharp/Spec_withoutStructure-xps/Resources/Fonts/33c063c8-1259-4322-acc8-8fc1964cc064.ODTTF differ
diff --git a/samples/snippets/csharp/VS_Snippets_Wpf/DocumentStructure/CSharp/Spec_withoutStructure-xps/Resources/Fonts/3b85141b-0969-4d9e-b9c8-e705bb7e6543.ODTTF b/samples/snippets/csharp/VS_Snippets_Wpf/DocumentStructure/CSharp/Spec_withoutStructure-xps/Resources/Fonts/3b85141b-0969-4d9e-b9c8-e705bb7e6543.ODTTF
new file mode 100644
index 00000000000..d8d0696e90c
Binary files /dev/null and b/samples/snippets/csharp/VS_Snippets_Wpf/DocumentStructure/CSharp/Spec_withoutStructure-xps/Resources/Fonts/3b85141b-0969-4d9e-b9c8-e705bb7e6543.ODTTF differ
diff --git a/samples/snippets/csharp/VS_Snippets_Wpf/DocumentStructure/CSharp/Spec_withoutStructure-xps/Resources/Fonts/3f87ce81-fb61-4ea7-8d62-aed569d1b895.ODTTF b/samples/snippets/csharp/VS_Snippets_Wpf/DocumentStructure/CSharp/Spec_withoutStructure-xps/Resources/Fonts/3f87ce81-fb61-4ea7-8d62-aed569d1b895.ODTTF
new file mode 100644
index 00000000000..a64452baba6
Binary files /dev/null and b/samples/snippets/csharp/VS_Snippets_Wpf/DocumentStructure/CSharp/Spec_withoutStructure-xps/Resources/Fonts/3f87ce81-fb61-4ea7-8d62-aed569d1b895.ODTTF differ
diff --git a/samples/snippets/csharp/VS_Snippets_Wpf/DocumentStructure/CSharp/Spec_withoutStructure-xps/Resources/Fonts/64326a24-1829-4393-8602-67e5b520db43.ODTTF b/samples/snippets/csharp/VS_Snippets_Wpf/DocumentStructure/CSharp/Spec_withoutStructure-xps/Resources/Fonts/64326a24-1829-4393-8602-67e5b520db43.ODTTF
new file mode 100644
index 00000000000..a026d3b90d3
Binary files /dev/null and b/samples/snippets/csharp/VS_Snippets_Wpf/DocumentStructure/CSharp/Spec_withoutStructure-xps/Resources/Fonts/64326a24-1829-4393-8602-67e5b520db43.ODTTF differ
diff --git a/samples/snippets/csharp/VS_Snippets_Wpf/DocumentStructure/CSharp/Spec_withoutStructure-xps/Resources/Fonts/9aa4ea89-755c-4331-be84-0cd43ff87195.ODTTF b/samples/snippets/csharp/VS_Snippets_Wpf/DocumentStructure/CSharp/Spec_withoutStructure-xps/Resources/Fonts/9aa4ea89-755c-4331-be84-0cd43ff87195.ODTTF
new file mode 100644
index 00000000000..59e15b9567d
Binary files /dev/null and b/samples/snippets/csharp/VS_Snippets_Wpf/DocumentStructure/CSharp/Spec_withoutStructure-xps/Resources/Fonts/9aa4ea89-755c-4331-be84-0cd43ff87195.ODTTF differ
diff --git a/samples/snippets/csharp/VS_Snippets_Wpf/DocumentStructure/CSharp/Spec_withoutStructure-xps/Resources/Images/Image_1.png b/samples/snippets/csharp/VS_Snippets_Wpf/DocumentStructure/CSharp/Spec_withoutStructure-xps/Resources/Images/Image_1.png
new file mode 100644
index 00000000000..f794f2e524b
Binary files /dev/null and b/samples/snippets/csharp/VS_Snippets_Wpf/DocumentStructure/CSharp/Spec_withoutStructure-xps/Resources/Images/Image_1.png differ
diff --git a/samples/snippets/csharp/VS_Snippets_Wpf/DocumentStructure/CSharp/Spec_withoutStructure-xps/Resources/Images/Image_2.png b/samples/snippets/csharp/VS_Snippets_Wpf/DocumentStructure/CSharp/Spec_withoutStructure-xps/Resources/Images/Image_2.png
new file mode 100644
index 00000000000..23925f0b825
Binary files /dev/null and b/samples/snippets/csharp/VS_Snippets_Wpf/DocumentStructure/CSharp/Spec_withoutStructure-xps/Resources/Images/Image_2.png differ
diff --git a/samples/snippets/csharp/VS_Snippets_Wpf/DocumentStructure/CSharp/Spec_withoutStructure-xps/Resources/Images/Image_3.png b/samples/snippets/csharp/VS_Snippets_Wpf/DocumentStructure/CSharp/Spec_withoutStructure-xps/Resources/Images/Image_3.png
new file mode 100644
index 00000000000..31029e93643
Binary files /dev/null and b/samples/snippets/csharp/VS_Snippets_Wpf/DocumentStructure/CSharp/Spec_withoutStructure-xps/Resources/Images/Image_3.png differ
diff --git a/samples/snippets/csharp/VS_Snippets_Wpf/DocumentStructure/CSharp/Spec_withoutStructure-xps/Resources/Images/Image_4.png b/samples/snippets/csharp/VS_Snippets_Wpf/DocumentStructure/CSharp/Spec_withoutStructure-xps/Resources/Images/Image_4.png
new file mode 100644
index 00000000000..29da46a89ec
Binary files /dev/null and b/samples/snippets/csharp/VS_Snippets_Wpf/DocumentStructure/CSharp/Spec_withoutStructure-xps/Resources/Images/Image_4.png differ
diff --git a/samples/snippets/csharp/VS_Snippets_Wpf/DocumentStructure/CSharp/Spec_withoutStructure-xps/Resources/Images/Image_5.png b/samples/snippets/csharp/VS_Snippets_Wpf/DocumentStructure/CSharp/Spec_withoutStructure-xps/Resources/Images/Image_5.png
new file mode 100644
index 00000000000..70e57c28ddb
Binary files /dev/null and b/samples/snippets/csharp/VS_Snippets_Wpf/DocumentStructure/CSharp/Spec_withoutStructure-xps/Resources/Images/Image_5.png differ
diff --git a/samples/snippets/csharp/VS_Snippets_Wpf/DocumentStructure/CSharp/Spec_withoutStructure-xps/[Content_Types].xml b/samples/snippets/csharp/VS_Snippets_Wpf/DocumentStructure/CSharp/Spec_withoutStructure-xps/[Content_Types].xml
new file mode 100644
index 00000000000..e69b9697260
--- /dev/null
+++ b/samples/snippets/csharp/VS_Snippets_Wpf/DocumentStructure/CSharp/Spec_withoutStructure-xps/[Content_Types].xml
@@ -0,0 +1,9 @@
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/samples/snippets/csharp/VS_Snippets_Wpf/DocumentStructure/CSharp/Spec_withoutStructure-xps/_rels/.rels b/samples/snippets/csharp/VS_Snippets_Wpf/DocumentStructure/CSharp/Spec_withoutStructure-xps/_rels/.rels
new file mode 100644
index 00000000000..b418a20901b
--- /dev/null
+++ b/samples/snippets/csharp/VS_Snippets_Wpf/DocumentStructure/CSharp/Spec_withoutStructure-xps/_rels/.rels
@@ -0,0 +1,5 @@
+
+
+
+
\ No newline at end of file
diff --git a/samples/snippets/csharp/VS_Snippets_Wpf/DocumentStructure/CSharp/Window1.xaml b/samples/snippets/csharp/VS_Snippets_Wpf/DocumentStructure/CSharp/Window1.xaml
new file mode 100644
index 00000000000..ea2097eb0b4
--- /dev/null
+++ b/samples/snippets/csharp/VS_Snippets_Wpf/DocumentStructure/CSharp/Window1.xaml
@@ -0,0 +1,112 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Status
+
+
+
+
+
+
+
+
+
+
+
+ Description
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/samples/snippets/csharp/VS_Snippets_Wpf/DocumentStructure/CSharp/Window1.xaml.cs b/samples/snippets/csharp/VS_Snippets_Wpf/DocumentStructure/CSharp/Window1.xaml.cs
new file mode 100644
index 00000000000..06b81db1a21
--- /dev/null
+++ b/samples/snippets/csharp/VS_Snippets_Wpf/DocumentStructure/CSharp/Window1.xaml.cs
@@ -0,0 +1,551 @@
+// DocumentStructure SDK Sample - Window1.xaml.cs
+// Copyright (c) Microsoft Corporation. All rights reserved.
+
+using System;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Documents;
+using System.Windows.Input;
+using System.Windows.Xps.Packaging;
+using System.Xml;
+using System.IO;
+using System.IO.Packaging;
+using System.Collections.Generic;
+using WinForms = Microsoft.Win32;
+
+namespace SdkSample
+{
+ ///
+ /// Interaction logic for Window1.xaml
+ public partial class Window1 : Window
+ {
+ #region constructor
+ // ------------------------ Window1 constructor -----------------------
+ public Window1() : base()
+ {
+ InitializeComponent();
+
+ ShowPrompt("Click 'File | Open...' and select the file " +
+ "'Spec_withoutStructure.xps'.");
+ ShowDescription(_descriptionString[0]);
+ }
+ #endregion constructor
+
+ #region File|Open...
+ // ------------------------------ OnOpen ------------------------------
+ ///
+ /// Handles the user "File | Open" menu operation.
+ private void OnOpen(object target, ExecutedRoutedEventArgs args)
+ {
+
+ // Create a "File Open" dialog positioned to the
+ // "Content\" folder containing the sample fixed document.
+ WinForms.OpenFileDialog dialog = new WinForms.OpenFileDialog();
+ dialog.InitialDirectory = GetContentFolder();
+ dialog.CheckFileExists = true;
+ dialog.Filter = "XPS Document files (*.xps)|*.xps|All (*.*)|*.*";
+
+ // Show the "File Open" dialog. If the user picks a file and
+ // clicks "OK", load and display the specified XPS document.
+ if (dialog.ShowDialog() != true) return;
+
+ // If the file is an XPS document, open it in the DocumentViewer.
+ if (dialog.FileName.EndsWith(".xps"))
+ {
+ OpenDocument(dialog.FileName);
+ }
+
+ // If the file is a text document, show it in the desciption block.
+ else if ( dialog.FileName.EndsWith(".xaml")
+ || dialog.FileName.EndsWith(".xml")
+ || dialog.FileName.EndsWith(".txt") )
+ {
+ using (StreamReader sr = new StreamReader(dialog.FileName))
+ {
+ ShowDescriptionTitle(Filename(dialog.FileName));
+ ShowDescription(sr.ReadToEnd(), TextWrapping.NoWrap);
+ }// end:using StreamReader(flush and close)
+ ShowPrompt("");
+ }
+ }// end:OnOpen()
+
+ // --------------------------- OpenDocument ---------------------------
+ ///
+ /// Opens a specified XPS document in given access mode.
+ ///
+ /// The path and file name of the XPS document to open.
+ private bool OpenDocument(string xpsFile)
+ {
+ // Close the XpsDocument if it is currently open.
+ if (_xpsDocument != null) CloseDocument();
+
+ // Load and create an in-memory instance of the XPS document.
+ ShowStatus("Opening '" + Filename(xpsFile) + "'.");
+ _xpsDocument = new XpsDocument(xpsFile, FileAccess.Read);
+
+ // Get the FixedDocumentSequence from the XPS document.
+ FixedDocumentSequence fds = _xpsDocument.GetFixedDocumentSequence();
+ if (fds == null)
+ {
+ string msg = xpsFile +
+ "\n\nThe document package within the specified " +
+ "file does not contain a FixedDocumentSequence.";
+ MessageBox.Show(msg, "Package Error");
+ return false;
+ }
+
+ // Load the FixedDocumentSequence to the DocumentViewer control.
+ DocViewer.Document = fds;
+
+ string filename = Filename(xpsFile).ToLower();
+ if (filename.Equals("spec_withoutstructure.xps"))
+ {
+ ShowPrompt("Click 'File | Open...' and select the file " +
+ "'Spec_withStructure.xps'.");
+ ShowDescription(_descriptionString[2]);
+ }
+ else if (filename.Equals("spec_withstructure.xps"))
+ {
+ ShowPrompt("Click 'File | Add Structure...'.");
+ ShowDescription(_descriptionString[3] + _descriptionString[4]);
+ }
+ else
+ {
+ ShowPrompt("");
+ }
+
+ _openedXpsFile = xpsFile;
+ menuFileClose.IsEnabled = true;
+ menuFilePrint.IsEnabled = true;
+ descriptionBlockTitle.Text = "Description";
+ this.Title = "DocumentStructure Sample - " + Filename(xpsFile);
+ return true;
+ }// OpenDocument()
+ #endregion File|Open...
+
+ #region File|Close
+ // ----------------------------- OnClosed -----------------------------
+ ///
+ /// Performs clean up when the application is closed.
+ private void OnClosed(object sender, EventArgs e)
+ {
+ CloseDocument();
+ }// end:OnClosed()
+
+ // ----------------------------- OnClose ------------------------------
+ ///
+ /// Handles the user "File | Close" menu operation
+ /// to close the currently open document.
+ private void OnClose(object target, ExecutedRoutedEventArgs args)
+ {
+ CloseDocument();
+ }// end:OnClose()
+
+ // -------------------------- CloseDocument ---------------------------
+ ///
+ /// Closes the document if its open.
+ private void CloseDocument()
+ {
+ if (_xpsDocument != null)
+ {
+ ShowStatus("Closing '" + Filename(_openedXpsFile) + "'.");
+ _xpsDocument.Close();
+ _xpsDocument = null;
+ _openedXpsFile = null;
+ DocViewer.Document = null;
+ }
+
+ ShowPrompt("Click 'File | Open...' and select the file " +
+ "'Spec_withoutStructure.xps'.");
+ ShowDescription(_descriptionString[0]);
+ menuFilePrint.IsEnabled = false;
+ menuFileClose.IsEnabled = false;
+ this.Title = "DocumentStructure Sample";
+ }// end:CloseDocument
+ #endregion File|Close
+
+ #region File|Add Structure...
+ // -------------------------- OnAddStructure --------------------------
+ ///
+ /// Handles the user File|Add Structure... menu option to
+ /// add structure elements to an unstructured XPS document.
+ private void OnAddStructure(object sender, EventArgs e)
+ {
+ /*-----
+ // Create a "File Open" dialog positioned to the
+ // "Content\" folder containing the sample XPS documents.
+ WinForms.OpenFileDialog openDialog = new WinForms.OpenFileDialog();
+ openDialog.InitialDirectory = GetContentFolder();
+ openDialog.Title = "Source Unstructured XPS Document";
+ openDialog.CheckFileExists = true;
+ openDialog.Filter = "XPS Documents " +
+ "(*_withoutStructure.xps)|*_withoutStructure.xps|All (*.*)|*.*";
+
+ // Show the "File Open" dialog. If the user picks a file and
+ // clicks "OK", set it as the XPS unstructured file.
+ if (openDialog.ShowDialog() != true) return;
+ string xpsUnstructuredFile = openDialog.FileName;
+ -----*/
+ // For the sample, always use "Spec_withoutStructure.xps"
+ // as the source unstructured document file.
+ string xpsUnstructuredFile = GetContentFolder() +
+ "\\Spec_withoutStructure.xps";
+
+ // Create a "File Save" dialog positioned to the
+ // "Content\" folder to write the new structured document to.
+ WinForms.SaveFileDialog saveDialog = new WinForms.SaveFileDialog();
+ saveDialog.OverwritePrompt = false;
+ saveDialog.InitialDirectory = GetContentFolder();
+ saveDialog.Title = "Save New Structured XPS Document As";
+ saveDialog.Filter = "XPS Documents (*.xps)|*.xps|All (*.*)|*.*";
+
+ // Set a default XPS document filename.
+ saveDialog.FileName = GetContentFolder() + @"\Structured.xps";
+
+ // Show the "File Save" dialog. If the user picks a file and
+ // clicks "OK", set it as the target ouput XPS structured file.
+ if (saveDialog.ShowDialog() != true) return;
+ string xpsTargetFile = saveDialog.FileName;
+
+ // Add the document structure resource elements
+ // to create a new structured XPS document.
+ AddDocumentStructure(xpsUnstructuredFile, // source unstructured doc
+ _fixedPageStructures, // structure definitions
+ xpsTargetFile); // target structured doc
+ }// end:OnAddStructure()
+
+ // ----------------------- AddDocumentStructure -----------------------
+ ///
+ /// Writes a structured XPS document given an unstructured document
+ /// and a file list of XAML document structure elements to add.
+ ///
+ /// The path and filename of the unstructured XPS document.
+ ///
+ /// A file list of XAML document structures to add.
+ ///
+ /// The path and filename for the new structured
+ /// XPS document to write.
+ ///
+ /// If xpsTargetFile exists, it is first deleted and
+ /// then a new structured XPS document written.
+ private void AddDocumentStructure(
+ string xpsUnstructuredFile, // source unstructured document
+ string[] xamlStructureFile, // structure definition resources
+ string xpsTargetFile) // target structured XPS document
+ {
+ // Close the current document if one is open.
+ CloseDocument();
+
+ ShowStatus("\nCreating new structured XPS\n " +
+ "document '" + Filename(xpsTargetFile) + "'.");
+
+ // If the new target XPS file exists, prompt to confirm ok to replace.
+ if (File.Exists(xpsTargetFile))
+ {
+ MessageBoxResult result = MessageBox.Show("'"+ xpsTargetFile+
+ "' already exists.\nDo you want to delete and replace it?",
+ "Ok to replace '" + Filename(xpsTargetFile) + "'?",
+ MessageBoxButton.YesNo, MessageBoxImage.Question);
+ if (result != MessageBoxResult.Yes) return;
+ ShowStatus(" Deleting old '" +
+ Filename(xpsTargetFile) + "'.");
+ File.Delete(xpsTargetFile);
+ }
+
+ ShowStatus(" Copying '" + Filename(xpsUnstructuredFile) +
+ "'\n to '" + Filename(xpsTargetFile) + "'.");
+ File.Copy(xpsUnstructuredFile, xpsTargetFile);
+
+ ShowStatus(" Opening '" + Filename(xpsTargetFile) +
+ "'\n (currently without structure).");
+ //
+ //
+ XpsDocument xpsDocument = null;
+ try
+ {
+ xpsDocument =
+ new XpsDocument(xpsTargetFile, FileAccess.ReadWrite);
+ }
+ catch (System.IO.FileFormatException)
+ {
+ string msg = xpsUnstructuredFile + "\n\nThe specified file " +
+ "does not appear to be a valid XPS document.";
+ MessageBox.Show(msg, "Invalid File Format",
+ MessageBoxButton.OK, MessageBoxImage.Error);
+ ShowStatus(" Invalid XPS document format.");
+ return;
+ }
+ //
+
+ //
+ ShowStatus(" Getting FixedDocumentSequenceReader.");
+ IXpsFixedDocumentSequenceReader fixedDocSeqReader =
+ xpsDocument.FixedDocumentSequenceReader;
+
+ ShowStatus(" Getting FixedDocumentReaders.");
+ ICollection fixedDocuments =
+ fixedDocSeqReader.FixedDocuments;
+
+ ShowStatus(" Getting FixedPageReaders.");
+ IEnumerator enumerator =
+ fixedDocuments.GetEnumerator();
+ enumerator.MoveNext();
+ ICollection fixedPages =
+ enumerator.Current.FixedPages;
+
+ // Add a document structure to each fixed page.
+ int i = 0;
+ foreach (IXpsFixedPageReader fixedPageReader in fixedPages)
+ {
+ XpsResource pageStructure;
+ ShowStatus(" Adding page structure resource:\n '" +
+ Filename(_fixedPageStructures[i]) + "'");
+ try
+ { // Add a new StoryFragment to hold the page structure.
+ pageStructure = fixedPageReader.AddStoryFragment();
+ }
+ catch (System.InvalidOperationException)
+ {
+ MessageBox.Show(xpsUnstructuredFile +
+ "\n\nDocument structure cannot be added.\n\n" +
+ Filename(xpsUnstructuredFile) + " might already " +
+ "contain an existing document structure.",
+ "Cannot Add Document Structure",
+ MessageBoxButton.OK, MessageBoxImage.Error);
+ break;
+ }
+
+ // Copy the page structure to the new StoryFragment.
+ WriteResource(pageStructure, _fixedPageStructures[i++]);
+ }
+
+ ShowStatus(" Saving and closing the new document.\n");
+ xpsDocument.Close();
+ //
+ //
+
+ // Open the new structured document.
+ OpenDocument(xpsTargetFile);
+
+ ShowDescription(_descriptionString[4] + _descriptionString[5]);
+ ShowPrompt(_descriptionString[5]);
+ }// end:AddDocumentStructure
+ #endregion File|Add Structure...
+
+ #region File|Print
+ // ----------------------------- OnPrint ------------------------------
+ ///
+ /// Handles the user "File | Print" menu operation.
+ private void OnPrint(object target, ExecutedRoutedEventArgs args)
+ {
+ PrintDocument();
+ }// end:OnClose()
+
+ // -------------------------- PrintDocument ---------------------------
+ ///
+ /// Prints the DocumentViewer's content and annotations.
+ public void PrintDocument()
+ {
+ if (DocViewer == null) return;
+ DocViewer.Print();
+ }// end:PrintDocument()
+ #endregion File|Print
+
+ #region File|Exit
+ // ------------------------------ OnExit ------------------------------
+ ///
+ /// Handles the user File|Exit menu selection to
+ /// shutdown and exit the application.
+ private void OnExit(object sender, EventArgs e)
+ {
+ Close(); // invokes OnClosed()
+ }// end:OnExit()
+ #endregion File|Exit
+
+ #region Utilities
+ // ------------------------- GetContentFolder -------------------------
+ ///
+ /// Locates and returns the path to the "Content\" folder
+ /// containing the content files for the sample.
+ ///
+ /// The path to the sample "Content\" folder.
+ public string GetContentFolder()
+ {
+ // Get the path to the current directory and its length.
+ string contentDir = Directory.GetCurrentDirectory();
+ int dirLength = contentDir.Length;
+
+ // If we're in "...\bin\debug", move up to the root.
+ if (contentDir.ToLower().EndsWith(@"\bin\debug"))
+ contentDir = contentDir.Remove(dirLength - 10, 10);
+
+ // If we're in "...\bin\release", move up to the root.
+ else if (contentDir.ToLower().EndsWith(@"\bin\release"))
+ contentDir = contentDir.Remove(dirLength - 12, 12);
+
+ // If there's a "Content" subfolder, that's what we want.
+ if (Directory.Exists(contentDir + @"\Content"))
+ contentDir = contentDir + @"\Content";
+
+ // Return the "Content\" folder (or the "current"
+ // directory if we're executing somewhere else).
+ return contentDir;
+ }// end:GetContentFolder()
+
+ // -------------------------- WriteResource ---------------------------
+ void WriteResource(XpsResource resource, string filename)
+ {
+ WriteStream(resource.GetStream(), filename);
+ }
+
+ // --------------------------- WriteStream ----------------------------
+ private void WriteStream(Stream stream, string filename)
+ {
+ FileStream srcStream = new FileStream(
+ filename, FileMode.Open, FileAccess.Read, FileShare.Read);
+
+ byte[] buf = new byte[65536];
+ int bytesRead;
+
+ do
+ {
+ bytesRead = srcStream.Read(buf, 0, 65536);
+ stream.Write(buf, 0, bytesRead);
+ }
+ while (bytesRead > 0);
+
+ srcStream.Close();
+ }// end:WriteStream()
+
+ // ------------------------- ShowPrompt(string) -----------------------
+ ///
+ /// Writes a line of text to the prompt bar.
+ ///
+ /// The line of text to write in the prompt bar.
+ public void ShowPrompt(string prompt)
+ {
+ promptBlock.Text = prompt;
+ }
+
+ // ---------------------------- ShowStatus ----------------------------
+ ///
+ /// Adds a line of text to the statusBlock.
+ ///
+ /// A line of text to add to the status TextBlock.
+ public void ShowStatus(string status)
+ {
+ statusBlock.Text += status + "\n";
+ }
+
+ // ------------------------- ShowDescription -------------------------
+ ///
+ /// Displays a string of text to the description block.
+ public void ShowDescription(string description)
+ {
+ descriptionBlock.Text = description;
+ descriptionBlock.TextWrapping = TextWrapping.Wrap;
+ }
+
+ // ------------------------- ShowDescription -------------------------
+ ///
+ /// Displays a string of text to the description block.
+ public void ShowDescription(string description, TextWrapping wrapStyle)
+ {
+ descriptionBlock.Text = description;
+ descriptionBlock.TextWrapping = wrapStyle;
+ }
+
+ // ----------------------- ShowDescriptionTitle -----------------------
+ ///
+ /// Displays a string of text in the description title block.
+ public void ShowDescriptionTitle(string title)
+ {
+ descriptionBlockTitle.Text = title;
+ }
+
+ // ------------------------------ Filename ----------------------------
+ ///
+ /// Returns just the filename from a given path and filename.
+ ///
+ /// A path and filename.
+ ///
+ /// The filename with extension.
+ private static string Filename(string filepath)
+ {
+ // Locate the index of the last backslash.
+ int slashIndex = filepath.LastIndexOf('\\');
+
+ // If there is no backslash, return the original string.
+ if (slashIndex < 0)
+ return filepath;
+
+ // Remove all the characters through the last backslash.
+ return filepath.Remove(0, slashIndex + 1);
+ }
+
+ // ----------------------- DocViewer attribute ------------------------
+ ///
+ /// Gets the current DocumentViewer.
+ public DocumentViewer DocViewer
+ {
+ get
+ { return docViewer; } // "docViewer" declared in Window1.xaml
+ }
+ #endregion Utilities
+
+ #region Private Fields
+ private string _openedXpsFile = null; // XPS document path & filename.
+ private XpsDocument _xpsDocument = null; // current XpsDocument.
+
+ // Document structure resource files.
+ private static string[] _fixedPageStructures =
+ {
+ "FixedPage1_structure.xaml", // document structure elements, page 1
+ "FixedPage2_structure.xaml" // document structure elements, page 2
+ };
+
+ // Description block text strings.
+ private static string[] _descriptionString =
+ {
+ //Step 0
+ "The DocumentStructure example includes two sample XPS documents:\n"+
+ " 1. Spec_withoutStructure.xps\n" +
+ " 2. Spec_withStructure.xps\n\n" +
+ "When you open each file note that the visual layout, " +
+ "quality, and print output of both documents is exactly " +
+ "the same - both documents fully conform to the open XML " +
+ "Paper Specification (XPS). Cutting and pasting information " +
+ "from each document, however, is quite different.\n\nClick " +
+ "'File | Open...', select the file " +
+ "'Spec_withoutStructure.xps', and then click OK.",
+ //Step 1
+ "Click 'File | Open...', select the file " +
+ "'Spec_withoutStructure.xps', and then click OK.",
+ //Step 2
+ "Within the 'Spec_withoutStructure.xps' document select a portion " +
+ "of Table 1-1 and paste it into a blank Word or WordPad " +
+ "document. Notice that an XPS document without structure " +
+ "elements pastes as plain text not as a formatted table.\n\n" +
+ "Next click 'File | Open...' and select " +
+ "'Spec_withStructure.xps'.",
+ //Step 3
+ "Select a portion of "+
+ "Table 1-1 and paste it into the Word or WordPad document. " +
+ "Notice that a document with structure elements uses rich " +
+ "text to paste the selection as styled table elements.\n\n" +
+ "Next click 'File | Add Structure...'\n\n",
+ //Step 4
+ "The Add Structure process copies 'Spec_withoutStructure.xps' " +
+ "to a new file and then programatically adds to the new " +
+ "document the two structure elements contained in:\n - " +
+ "FixedPage1_structure.xaml\n - FixedPage2_structure.xaml\n\n"+
+ "The resulting new XPS document is equivalent " +
+ "to 'Spec_withStructure.xps'.\n\n",
+ //Step 5
+ "Click 'File | Open...' and set 'Files of Type' to 'All' " +
+ "to select a .xaml document structure resource file to view."
+ };
+ #endregion Private Fields
+
+ }// end:partial class Window1
+}// end:namespace SdkSample
diff --git a/samples/snippets/csharp/api/system.collections.concurrent/concurrentbag/concbag.cs b/samples/snippets/csharp/api/system.collections.concurrent/concurrentbag/concbag.cs
new file mode 100644
index 00000000000..8340f538000
--- /dev/null
+++ b/samples/snippets/csharp/api/system.collections.concurrent/concurrentbag/concbag.cs
@@ -0,0 +1,54 @@
+//
+using System;
+using System.Collections.Concurrent;
+using System.Collections.Generic;
+using System.Threading.Tasks;
+
+class ConcurrentBagDemo
+{
+ // Demonstrates:
+ // ConcurrentBag.Add()
+ // ConcurrentBag.IsEmpty
+ // ConcurrentBag.TryTake()
+ // ConcurrentBag.TryPeek()
+ static void Main()
+ {
+ // Add to ConcurrentBag concurrently
+ ConcurrentBag cb = new ConcurrentBag();
+ List bagAddTasks = new List();
+ for (int i = 0; i < 500; i++)
+ {
+ var numberToAdd = i;
+ bagAddTasks.Add(Task.Run(() => cb.Add(numberToAdd)));
+ }
+
+ // Wait for all tasks to complete
+ Task.WaitAll(bagAddTasks.ToArray());
+
+ // Consume the items in the bag
+ List bagConsumeTasks = new List();
+ int itemsInBag = 0;
+ while (!cb.IsEmpty)
+ {
+ bagConsumeTasks.Add(Task.Run(() =>
+ {
+ int item;
+ if (cb.TryTake(out item))
+ {
+ Console.WriteLine(item);
+ itemsInBag++;
+ }
+ }));
+ }
+ Task.WaitAll(bagConsumeTasks.ToArray());
+
+ Console.WriteLine($"There were {itemsInBag} items in the bag");
+
+ // Checks the bag for an item
+ // The bag should be empty and this should not print anything
+ int unexpectedItem;
+ if (cb.TryPeek(out unexpectedItem))
+ Console.WriteLine("Found an item in the bag when it should be empty");
+ }
+}
+//
diff --git a/samples/snippets/csharp/api/system.collections/icomparer/reverse.cs b/samples/snippets/csharp/api/system.collections/icomparer/reverse.cs
new file mode 100644
index 00000000000..9b05f78be4b
--- /dev/null
+++ b/samples/snippets/csharp/api/system.collections/icomparer/reverse.cs
@@ -0,0 +1,77 @@
+using System;
+using System.Collections;
+
+public class Example
+{
+ public class ReverserClass : IComparer
+ {
+ // Call CaseInsensitiveComparer.Compare with the parameters reversed.
+ int IComparer.Compare(Object x, Object y)
+ {
+ return ((new CaseInsensitiveComparer()).Compare(y, x));
+ }
+ }
+
+ public static void Main()
+ {
+ // Initialize a string array.
+ string[] words = { "The", "quick", "brown", "fox", "jumps", "over",
+ "the", "lazy", "dog" };
+
+ // Display the array values.
+ Console.WriteLine("The array initially contains the following values:" );
+ PrintIndexAndValues(words);
+
+ // Sort the array values using the default comparer.
+ Array.Sort(words);
+ Console.WriteLine("After sorting with the default comparer:" );
+ PrintIndexAndValues(words);
+
+ // Sort the array values using the reverse case-insensitive comparer.
+ Array.Sort(words, new ReverserClass());
+ Console.WriteLine("After sorting with the reverse case-insensitive comparer:");
+ PrintIndexAndValues(words);
+ }
+
+ public static void PrintIndexAndValues(IEnumerable list)
+ {
+ int i = 0;
+ foreach (var item in list )
+ Console.WriteLine($" [{i++}]: {item}");
+
+ Console.WriteLine();
+ }
+}
+// The example displays the following output:
+// The array initially contains the following values:
+// [0]: The
+// [1]: quick
+// [2]: brown
+// [3]: fox
+// [4]: jumps
+// [5]: over
+// [6]: the
+// [7]: lazy
+// [8]: dog
+//
+// After sorting with the default comparer:
+// [0]: brown
+// [1]: dog
+// [2]: fox
+// [3]: jumps
+// [4]: lazy
+// [5]: over
+// [6]: quick
+// [7]: the
+// [8]: The
+//
+// After sorting with the reverse case-insensitive comparer:
+// [0]: the
+// [1]: The
+// [2]: quick
+// [3]: over
+// [4]: lazy
+// [5]: jumps
+// [6]: fox
+// [7]: dog
+// [8]: brown
\ No newline at end of file
diff --git a/samples/snippets/csharp/api/system.diagnostics/process/standarderror/stderror-sync.cs b/samples/snippets/csharp/api/system.diagnostics/process/standarderror/stderror-sync.cs
new file mode 100644
index 00000000000..1097715c01b
--- /dev/null
+++ b/samples/snippets/csharp/api/system.diagnostics/process/standarderror/stderror-sync.cs
@@ -0,0 +1,23 @@
+using System;
+using System.Diagnostics;
+
+public class Example
+{
+ public static void Main()
+ {
+ var p = new Process();
+ p.StartInfo.UseShellExecute = false;
+ p.StartInfo.RedirectStandardError = true;
+ p.StartInfo.FileName = "Write500Lines.exe";
+ p.Start();
+
+ // To avoid deadlocks, always read the output stream first and then wait.
+ string output = p.StandardError.ReadToEnd();
+ p.WaitForExit();
+
+ Console.WriteLine($"\nError stream: {output}");
+ }
+}
+// The end of the output produced by the example includes the following:
+// Error stream:
+// Successfully wrote 500 lines.
\ No newline at end of file
diff --git a/samples/snippets/csharp/api/system.diagnostics/process/standardoutput/stdoutput-async.cs b/samples/snippets/csharp/api/system.diagnostics/process/standardoutput/stdoutput-async.cs
new file mode 100644
index 00000000000..33891833cf6
--- /dev/null
+++ b/samples/snippets/csharp/api/system.diagnostics/process/standardoutput/stdoutput-async.cs
@@ -0,0 +1,33 @@
+using System;
+using System.Diagnostics;
+
+public class Example
+{
+ public static void Main()
+ {
+ var p = new Process();
+ p.StartInfo.UseShellExecute = false;
+ p.StartInfo.RedirectStandardOutput = true;
+ string eOut = null;
+ p.StartInfo.RedirectStandardError = true;
+ p.ErrorDataReceived += new DataReceivedEventHandler((sender, e) =>
+ { eOut += e.Data; });
+ p.StartInfo.FileName = "Write500Lines.exe";
+ p.Start();
+
+ // To avoid deadlocks, use an asynchronous read operation on at least one of the streams.
+ p.BeginErrorReadLine();
+ string output = p.StandardOutput.ReadToEnd();
+ p.WaitForExit();
+
+ Console.WriteLine($"The last 50 characters in the output stream are:\n'{output.Substring(output.Length - 50)}'");
+ Console.WriteLine($"\nError stream: {eOut}");
+ }
+}
+// The example displays the following output:
+// The last 50 characters in the output stream are:
+// ' 49,800.20%
+// Line 500 of 500 written: 49,900.20%
+// '
+//
+// Error stream: Successfully wrote 500 lines.
diff --git a/samples/snippets/csharp/api/system.diagnostics/process/standardoutput/stdoutput-sync.cs b/samples/snippets/csharp/api/system.diagnostics/process/standardoutput/stdoutput-sync.cs
new file mode 100644
index 00000000000..8f36ad27f02
--- /dev/null
+++ b/samples/snippets/csharp/api/system.diagnostics/process/standardoutput/stdoutput-sync.cs
@@ -0,0 +1,27 @@
+using System;
+using System.Diagnostics;
+
+public class Example
+{
+ public static void Main()
+ {
+ var p = new Process();
+ p.StartInfo.UseShellExecute = false;
+ p.StartInfo.RedirectStandardOutput = true;
+ p.StartInfo.FileName = "Write500Lines.exe";
+ p.Start();
+
+ // To avoid deadlocks, always read the output stream first and then wait.
+ string output = p.StandardOutput.ReadToEnd();
+ p.WaitForExit();
+
+ Console.WriteLine($"The last 50 characters in the output stream are:\n'{output.Substring(output.Length - 50)}'");
+ }
+}
+// The example displays the following output:
+// Successfully wrote 500 lines.
+//
+// The last 50 characters in the output stream are:
+// ' 49,800.20%
+// Line 500 of 500 written: 49,900.20%
+// '
\ No newline at end of file
diff --git a/samples/snippets/csharp/api/system.diagnostics/process/standardoutput/write500lines.cs b/samples/snippets/csharp/api/system.diagnostics/process/standardoutput/write500lines.cs
new file mode 100644
index 00000000000..ed4b2e64675
--- /dev/null
+++ b/samples/snippets/csharp/api/system.diagnostics/process/standardoutput/write500lines.cs
@@ -0,0 +1,20 @@
+using System;
+using System.IO;
+
+public class Example
+{
+ public static void Main()
+ {
+ for (int ctr = 0; ctr < 500; ctr++)
+ Console.WriteLine($"Line {ctr + 1} of 500 written: {ctr + 1/500.0:P2}");
+
+ Console.Error.WriteLine("\nSuccessfully wrote 500 lines.\n");
+ }
+}
+// The example displays the following output:
+// The last 50 characters in the output stream are:
+// ' 49,800.20%
+// Line 500 of 500 written: 49,900.20%
+//'
+//
+// Error stream: Successfully wrote 500 lines.
\ No newline at end of file
diff --git a/samples/snippets/csharp/api/system.globalization/japanesecalendar/todatetime/Program.cs b/samples/snippets/csharp/api/system.globalization/japanesecalendar/todatetime/Program.cs
new file mode 100644
index 00000000000..4115c576534
--- /dev/null
+++ b/samples/snippets/csharp/api/system.globalization/japanesecalendar/todatetime/Program.cs
@@ -0,0 +1,31 @@
+using System;
+using System.Globalization;
+
+class Program
+{
+ static void Main()
+ {
+ var cal = new JapaneseCalendar();
+ var jaJp = new CultureInfo("ja-JP");
+ jaJp.DateTimeFormat.Calendar = cal;
+ var date1 = cal.ToDateTime(2,1,1,0,0,0,0,JapaneseCalendar.CurrentEra);
+ Console.WriteLine($"Japanese calendar date: {date1.ToString("D", jaJp)}, " +
+ $"Gregorian calendar date: {date1.ToString("D", CultureInfo.InvariantCulture)}");
+
+ var date2 = cal.ToDateTime(6,11,7,0,0,0,0,GetEraIndex("大正"));
+ Console.WriteLine($"Japanese calendar date: {date2.ToString("D", jaJp)}, " +
+ $"Gregorian calendar date: {date2.ToString("D", CultureInfo.InvariantCulture)}");
+
+ int GetEraIndex(string eraName)
+ {
+ foreach (var ctr in cal.Eras)
+ if (jaJp.DateTimeFormat.GetEraName(ctr) == eraName)
+ return ctr;
+
+ return 0;
+ }
+ }
+}
+// The example displays the following output:
+// Japanese calendar date: 平成2年1月1日, Gregorian calendar date: Monday, 01 January 1990
+// Japanese calendar date: 大正6年11月7日, Gregorian calendar date: Wednesday, 07 November 1917
diff --git a/samples/snippets/csharp/api/system.globalization/japanesecalendar/todatetime/todatetime.csproj b/samples/snippets/csharp/api/system.globalization/japanesecalendar/todatetime/todatetime.csproj
new file mode 100644
index 00000000000..7322fb30357
--- /dev/null
+++ b/samples/snippets/csharp/api/system.globalization/japanesecalendar/todatetime/todatetime.csproj
@@ -0,0 +1,8 @@
+
+
+
+ Exe
+ netcoreapp3.0
+
+
+
diff --git a/samples/snippets/csharp/api/system.io/path/IsPathRooted/Program.cs b/samples/snippets/csharp/api/system.io/path/IsPathRooted/Program.cs
new file mode 100644
index 00000000000..75415483f98
--- /dev/null
+++ b/samples/snippets/csharp/api/system.io/path/IsPathRooted/Program.cs
@@ -0,0 +1,41 @@
+using System;
+using System.IO;
+
+class Program
+{
+ static void Main()
+ {
+ string relative1 = "C:Documents";
+ ShowPathInfo(relative1);
+
+ string relative2 = "/Documents";
+ ShowPathInfo(relative2);
+
+ string absolute = "C:/Documents";
+ ShowPathInfo(absolute);
+ }
+
+ private static void ShowPathInfo(string path)
+ {
+ Console.WriteLine($"Path: {path}");
+ Console.WriteLine($" Rooted: {Path.IsPathRooted(path)}");
+ Console.WriteLine($" Fully qualified: {Path.IsPathFullyQualified(path)}");
+ Console.WriteLine($" Full path: {Path.GetFullPath(path)}");
+ Console.WriteLine();
+ }
+}
+// The example displays the following output when run on a Windows system:
+// Path: C:Documents
+// Rooted: True
+// Fully qualified: False
+// Full path: c:\Users\user1\Documents\projects\path\ispathrooted\Documents
+//
+// Path: /Documents
+// Rooted: True
+// Fully qualified: False
+// Full path: c:\Documents
+//
+// Path: C:/Documents
+// Rooted: True
+// Fully qualified: True
+// Full path: C:\Documents
\ No newline at end of file
diff --git a/samples/snippets/csharp/api/system.io/path/IsPathRooted/ispathrooted.csproj b/samples/snippets/csharp/api/system.io/path/IsPathRooted/ispathrooted.csproj
new file mode 100644
index 00000000000..01d5113289c
--- /dev/null
+++ b/samples/snippets/csharp/api/system.io/path/IsPathRooted/ispathrooted.csproj
@@ -0,0 +1,8 @@
+
+
+
+ Exe
+ netcoreapp2.2
+
+
+
diff --git a/samples/snippets/csharp/api/system.io/path/TryJoin/Program.cs b/samples/snippets/csharp/api/system.io/path/TryJoin/Program.cs
new file mode 100644
index 00000000000..8da85c4f10d
--- /dev/null
+++ b/samples/snippets/csharp/api/system.io/path/TryJoin/Program.cs
@@ -0,0 +1,16 @@
+using System;
+using System.IO;
+
+class Program
+{
+ static void Main()
+ {
+ int nChars = 0;
+ var buffer = new Span(new String(' ', 100).ToCharArray());
+ var flag = Path.TryJoin("C:/".AsSpan(), "Users/user1".AsSpan(), buffer, out nChars);
+ if (flag)
+ Console.WriteLine($"Wrote {nChars} characters: '{buffer.Slice(0, nChars).ToString()}'");
+ else
+ Console.WriteLine("Concatenation operation failed.");
+ }
+}
diff --git a/samples/snippets/csharp/api/system.io/path/TryJoin/tryjoin.csproj b/samples/snippets/csharp/api/system.io/path/TryJoin/tryjoin.csproj
new file mode 100644
index 00000000000..01d5113289c
--- /dev/null
+++ b/samples/snippets/csharp/api/system.io/path/TryJoin/tryjoin.csproj
@@ -0,0 +1,8 @@
+
+
+
+ Exe
+ netcoreapp2.2
+
+
+
diff --git a/samples/snippets/csharp/api/system.io/path/combine/Program.cs b/samples/snippets/csharp/api/system.io/path/combine/Program.cs
new file mode 100644
index 00000000000..b65aa3b8411
--- /dev/null
+++ b/samples/snippets/csharp/api/system.io/path/combine/Program.cs
@@ -0,0 +1,82 @@
+using System;
+using System.IO;
+
+class Program
+{
+ static void Main(string[] args)
+ {
+ Console.WriteLine("Path.Combine(String[])");
+ Combine1();
+ Console.WriteLine("\nPath.Combine(String,String)");
+ Combine2();
+ Console.WriteLine("\nPath.Combine(String,String,String)");
+ Combine3();
+ Console.WriteLine("\nPath.Combine(String,String,String,String)");
+ Combine4();
+ }
+
+ static void Combine1()
+ {
+ //
+ string[] paths = {@"d:\archives", "2001", "media", "images"};
+ string fullPath = Path.Combine(paths);
+ Console.WriteLine(fullPath);
+
+ paths = new string[] {@"d:\archives\", @"2001\", "media", "images"};
+ fullPath = Path.Combine(paths);
+ Console.WriteLine(fullPath);
+
+ paths = new string[] {"d:/archives/", "2001/", "media", "images"};
+ fullPath = Path.Combine(paths);
+ Console.WriteLine(fullPath);
+ // The example displays the following output if run on a Windows system:
+ // d:\archives\2001\media\images
+ // d:\archives\2001\media\images
+ // d:/archives/2001/media\images
+ //
+ // The example displays the following output if run on a Unix-based system:
+ // d:\archives/2001/media/images
+ // d:\archives\/2001\/media/images
+ // d:/archives/2001/media/images
+ //
+ }
+
+ private static void Combine2()
+ {
+ //
+ var result = Path.Combine(@"C:\Pictures\", "Saved Pictures");
+ Console.WriteLine(result);
+ // The example displays the following output if run on a Windows system:
+ // C:\Pictures\Saved Pictures
+ //
+ // The example displays the following output if run on a Unix-based system:
+ // C:\Pictures\/Saved Pictures
+ //
+ }
+
+ private static void Combine3()
+ {
+ //
+ var result = Path.Combine(@"C:\Pictures\", @"Saved Pictures\", "2019");
+ Console.WriteLine(result);
+ // The example displays the following output if run on a Windows system:
+ // C:\Pictures\Saved Pictures\2019
+ //
+ // The example displays the following output if run on a Unix-based system:
+ // C:\Pictures\/Saved Pictures\/2019
+ //
+ }
+
+ private static void Combine4()
+ {
+ //
+ var result = Path.Combine(@"C:\Pictures\", @"Saved Pictures\", @"2019\", @"Jan\");
+ Console.WriteLine(result);
+ // The example displays the following output if run on a Windows system:
+ // C:\Pictures\Saved Pictures\2019\Jan\
+ //
+ // The example displays the following output if run on a Unix-based system:
+ // C:\Pictures\Saved Pictures\2019\Jan\
+ //
+ }
+}
diff --git a/samples/snippets/csharp/api/system.io/path/combine/misc.csproj b/samples/snippets/csharp/api/system.io/path/combine/misc.csproj
new file mode 100644
index 00000000000..e5e0e164b25
--- /dev/null
+++ b/samples/snippets/csharp/api/system.io/path/combine/misc.csproj
@@ -0,0 +1,8 @@
+
+
+
+ Exe
+ netcoreapp2.1
+
+
+
diff --git a/samples/snippets/csharp/api/system.io/path/combine2/Program.cs b/samples/snippets/csharp/api/system.io/path/combine2/Program.cs
new file mode 100644
index 00000000000..30eafb58722
--- /dev/null
+++ b/samples/snippets/csharp/api/system.io/path/combine2/Program.cs
@@ -0,0 +1,40 @@
+using System;
+using System.IO;
+
+class Program
+{
+ static void Main()
+ {
+ var path1 = "C:/Program Files/";
+ var path2 = "Utilities/SystemUtilities";
+ ShowPathInformation(path1, path2);
+
+ path1 = "C:/";
+ path2 = "/Program Files";
+ ShowPathInformation(path1, path2);
+
+ path1 = "C:/Users/Public/Documents/";
+ path2 = "C:/Users/User1/Documents/Financial/";
+ ShowPathInformation(path1, path2);
+ }
+
+ private static void ShowPathInformation(string path1, string path2)
+ {
+ var result = Path.Join(path1.AsSpan(), path2.AsSpan());
+ Console.WriteLine($"Concatenating '{path1}' and '{path2}'");
+ Console.WriteLine($" Path.Join: '{result}'");
+ Console.WriteLine($" Path.Combine: '{Path.Combine(path1, path2)}'");
+ }
+}
+// The example displays the following output if run on a Windows system:
+// Concatenating 'C:/Program Files/' and 'Utilities/SystemUtilities'
+// Path.Join: 'C:/Program Files/Utilities/SystemUtilities'
+// Path.Combine: 'C:/Program Files/Utilities/SystemUtilities'
+//
+// Concatenating 'C:/' and '/Program Files'
+// Path.Join: 'C://Program Files'
+// Path.Combine: '/Program Files'
+//
+// Concatenating 'C:/Users/Public/Documents/' and 'C:/Users/User1/Documents/Financial/'
+// Path.Join: 'C:/Users/Public/Documents/C:/Users/User1/Documents/Financial/'
+// Path.Combine: 'C:/Users/User1/Documents/Financial/'
diff --git a/samples/snippets/csharp/api/system.io/path/combine2/combine.csproj b/samples/snippets/csharp/api/system.io/path/combine2/combine.csproj
new file mode 100644
index 00000000000..e5e0e164b25
--- /dev/null
+++ b/samples/snippets/csharp/api/system.io/path/combine2/combine.csproj
@@ -0,0 +1,8 @@
+
+
+
+ Exe
+ netcoreapp2.1
+
+
+
diff --git a/samples/snippets/csharp/api/system.io/path/combine3/Program.cs b/samples/snippets/csharp/api/system.io/path/combine3/Program.cs
new file mode 100644
index 00000000000..983c20c56fa
--- /dev/null
+++ b/samples/snippets/csharp/api/system.io/path/combine3/Program.cs
@@ -0,0 +1,44 @@
+using System;
+using System.IO;
+
+class Program
+{
+ static void Main()
+ {
+ string path1 = "C:/";
+ string path2 = "users/user1/documents";
+ string path3 = "letters";
+ ShowPathInformation(path1, path2, path3);
+
+ path1 = "D:/";
+ path2 = "/users/user1/documents";
+ path3 = "letters";
+ ShowPathInformation(path1, path2, path3);
+
+ path1 = "D:/";
+ path2 = "users/user1/documents";
+ path3 = "C:/users/user1/documents/data";
+ ShowPathInformation(path1, path2, path3);
+ }
+
+ private static void ShowPathInformation(string path1, string path2, string path3)
+ {
+ var result = Path.Join(path1.AsSpan(), path2.AsSpan(), path3.AsSpan());
+ Console.WriteLine($"Concatenating '{path1}, '{path2}', and `{path3}'");
+ Console.WriteLine($" Path.Join: '{result}'");
+ Console.WriteLine($" Path.Combine: '{Path.Combine(path1, path2, path3)}'");
+ Console.WriteLine($" {Path.GetFullPath(result)}");
+ }
+}
+// The example displays the following output if run on a Windows system:
+// Concatenating 'C:/, 'users/user1/documents', and `letters'
+// Path.Join: 'C:/users/user1/documents\letters'
+// Path.Combine: 'C:/users/user1/documents\letters'
+//
+// Concatenating 'D:/, '/users/user1/documents', and `letters'
+// Path.Join: 'D://users/user1/documents\letters'
+// Path.Combine: '/users/user1/documents\letters'
+//
+// Concatenating 'D:/, 'users/user1/documents', and `C:/users/user1/documents/data'
+// Path.Join: 'D:/users/user1/documents\C:/users/user1/documents/data'
+// Path.Combine: 'C:/users/user1/documents/data'
diff --git a/samples/snippets/csharp/api/system.io/path/combine3/combine.csproj b/samples/snippets/csharp/api/system.io/path/combine3/combine.csproj
new file mode 100644
index 00000000000..e5e0e164b25
--- /dev/null
+++ b/samples/snippets/csharp/api/system.io/path/combine3/combine.csproj
@@ -0,0 +1,8 @@
+
+
+
+ Exe
+ netcoreapp2.1
+
+
+
diff --git a/samples/snippets/csharp/api/system.io/path/directoryseparatorchar/Program.cs b/samples/snippets/csharp/api/system.io/path/directoryseparatorchar/Program.cs
new file mode 100644
index 00000000000..550f3c0d372
--- /dev/null
+++ b/samples/snippets/csharp/api/system.io/path/directoryseparatorchar/Program.cs
@@ -0,0 +1,39 @@
+using System;
+using System.IO;
+
+class Program
+{
+ static void Main()
+ {
+ Console.WriteLine($"Path.DirectorySeparatorChar: '{Path.DirectorySeparatorChar}'");
+ Console.WriteLine($"Path.AltDirectorySeparatorChar: '{Path.AltDirectorySeparatorChar}'");
+ Console.WriteLine($"Path.PathSeparator: '{Path.PathSeparator}'");
+ Console.WriteLine($"Path.VolumeSeparatorChar: '{Path.VolumeSeparatorChar}'");
+ var invalidChars = Path.GetInvalidPathChars();
+ Console.WriteLine($"Path.GetInvalidPathChars:");
+ for (int ctr = 0; ctr < invalidChars.Length; ctr++)
+ {
+ Console.Write($" U+{Convert.ToUInt16(invalidChars[ctr]):X4} ");
+ if ((ctr + 1) % 10 == 0) Console.WriteLine();
+ }
+ Console.WriteLine();
+ }
+}
+// The example displays the following output when run on a Windows system:
+// Path.DirectorySeparatorChar: '\'
+// Path.AltDirectorySeparatorChar: '/'
+// Path.PathSeparator: ';'
+// Path.VolumeSeparatorChar: ':'
+// Path.GetInvalidPathChars:
+// U+007C) U+0000) U+0001) U+0002) U+0003) U+0004) U+0005) U+0006) U+0007) U+0008)
+// U+0009) U+000A) U+000B) U+000C) U+000D) U+000E) U+000F) U+0010) U+0011) U+0012)
+// U+0013) U+0014) U+0015) U+0016) U+0017) U+0018) U+0019) U+001A) U+001B) U+001C)
+// U+001D) U+001E) U+001F)
+//
+// The example displays the following output when run on a Linux system:
+// Path.DirectorySeparatorChar: '/'
+// Path.AltDirectorySeparatorChar: '/'
+// Path.PathSeparator: ':'
+// Path.VolumeSeparatorChar: '/'
+// Path.GetInvalidPathChars:
+// U+0000
\ No newline at end of file
diff --git a/samples/snippets/csharp/api/system.io/path/directoryseparatorchar/directoryseparatorchar.csproj b/samples/snippets/csharp/api/system.io/path/directoryseparatorchar/directoryseparatorchar.csproj
new file mode 100644
index 00000000000..01d5113289c
--- /dev/null
+++ b/samples/snippets/csharp/api/system.io/path/directoryseparatorchar/directoryseparatorchar.csproj
@@ -0,0 +1,8 @@
+
+
+
+ Exe
+ netcoreapp2.2
+
+
+
diff --git a/samples/snippets/csharp/api/system.io/path/getfullpath/Program.cs b/samples/snippets/csharp/api/system.io/path/getfullpath/Program.cs
new file mode 100644
index 00000000000..b3b87b267e3
--- /dev/null
+++ b/samples/snippets/csharp/api/system.io/path/getfullpath/Program.cs
@@ -0,0 +1,23 @@
+using System;
+using System.IO;
+
+class Program
+{
+ static void Main()
+ {
+ string basePath = Environment.CurrentDirectory;
+ string relativePath = "./data/output.xml";
+
+ // Unexpectedly change the current directory.
+ Environment.CurrentDirectory = "C:/Users/Public/Documents/";
+
+ string fullPath = Path.GetFullPath(relativePath, basePath);
+ Console.WriteLine($"Current directory:\n {Environment.CurrentDirectory}");
+ Console.WriteLine($"Fully qualified path:\n {fullPath}");
+ }
+}
+// The example displays the following output:
+// Current directory:
+// C:\Users\Public\Documents
+// Fully qualified path:
+// C:\Utilities\data\output.xml
\ No newline at end of file
diff --git a/samples/snippets/csharp/api/system.io/path/getfullpath/getfullpath.csproj b/samples/snippets/csharp/api/system.io/path/getfullpath/getfullpath.csproj
new file mode 100644
index 00000000000..01d5113289c
--- /dev/null
+++ b/samples/snippets/csharp/api/system.io/path/getfullpath/getfullpath.csproj
@@ -0,0 +1,8 @@
+
+
+
+ Exe
+ netcoreapp2.2
+
+
+
diff --git a/samples/snippets/csharp/api/system.security.cryptography/hashalgorithm/example1.cs b/samples/snippets/csharp/api/system.security.cryptography/hashalgorithm/example1.cs
new file mode 100644
index 00000000000..0e5f03a62b3
--- /dev/null
+++ b/samples/snippets/csharp/api/system.security.cryptography/hashalgorithm/example1.cs
@@ -0,0 +1,65 @@
+using System;
+using System.Security.Cryptography;
+using System.Text;
+
+public class Program
+{
+ public static void Main()
+ {
+ string source = "Hello World!";
+ using (SHA256 sha256Hash = SHA256.Create())
+ {
+ string hash = GetHash(sha256Hash, source);
+
+ Console.WriteLine($"The SHA256 hash of {source} is: {hash}.");
+
+ Console.WriteLine("Verifying the hash...");
+
+ if (VerifyHash(sha256Hash, source, hash))
+ {
+ Console.WriteLine("The hashes are the same.");
+ }
+ else
+ {
+ Console.WriteLine("The hashes are not same.");
+ }
+ }
+ }
+
+ private static string GetHash(HashAlgorithm hashAlgorithm, string input)
+ {
+
+ // Convert the input string to a byte array and compute the hash.
+ byte[] data = hashAlgorithm.ComputeHash(Encoding.UTF8.GetBytes(input));
+
+ // Create a new Stringbuilder to collect the bytes
+ // and create a string.
+ var sBuilder = new StringBuilder();
+
+ // Loop through each byte of the hashed data
+ // and format each one as a hexadecimal string.
+ for (int i = 0; i < data.Length; i++)
+ {
+ sBuilder.Append(data[i].ToString("x2"));
+ }
+
+ // Return the hexadecimal string.
+ return sBuilder.ToString();
+ }
+
+ // Verify a hash against a string.
+ private static bool VerifyHash(HashAlgorithm hashAlgorithm, string input, string hash)
+ {
+ // Hash the input.
+ var hashOfInput = GetHash(hashAlgorithm, input);
+
+ // Create a StringComparer an compare the hashes.
+ StringComparer comparer = StringComparer.OrdinalIgnoreCase;
+
+ return comparer.Compare(hashOfInput, hash) == 0;
+ }
+}
+// The example displays the following output:
+// The SHA256 hash of Hello World! is: 7f83b1657ff1fc53b92dc18148a1d65dfc2d4b1fa3d677284addd200126d9069.
+// Verifying the hash...
+// The hashes are the same.
diff --git a/samples/snippets/csharp/api/system.xml.linq/xnode/readfrom/Program.cs b/samples/snippets/csharp/api/system.xml.linq/xnode/readfrom/Program.cs
new file mode 100644
index 00000000000..3691513628a
--- /dev/null
+++ b/samples/snippets/csharp/api/system.xml.linq/xnode/readfrom/Program.cs
@@ -0,0 +1,42 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Xml;
+using System.Xml.Linq;
+
+class Program
+{
+ static IEnumerable StreamRootChildDoc(string uri)
+ {
+ using (XmlReader reader = XmlReader.Create(uri))
+ {
+ reader.MoveToContent();
+
+ // Parse the file and return each of the nodes.
+ while (!reader.EOF)
+ {
+ if (reader.NodeType == XmlNodeType.Element && reader.Name == "Child")
+ {
+ XElement el = XElement.ReadFrom(reader) as XElement;
+ if (el != null)
+ yield return el;
+ }
+ else
+ {
+ reader.Read();
+ }
+ }
+ }
+ }
+
+ static void Main(string[] args)
+ {
+ IEnumerable grandChildData =
+ from el in StreamRootChildDoc("Source.xml")
+ where (int)el.Attribute("Key") > 1
+ select (string)el.Element("GrandChild");
+
+ foreach (string str in grandChildData)
+ Console.WriteLine(str);
+ }
+}
\ No newline at end of file
diff --git a/samples/snippets/csharp/api/system.xml.linq/xnode/readfrom/Source.xml b/samples/snippets/csharp/api/system.xml.linq/xnode/readfrom/Source.xml
new file mode 100644
index 00000000000..b823058ec1c
--- /dev/null
+++ b/samples/snippets/csharp/api/system.xml.linq/xnode/readfrom/Source.xml
@@ -0,0 +1,12 @@
+
+
+
+ aaa
+
+
+ bbb
+
+
+ ccc
+
+
\ No newline at end of file
diff --git a/samples/snippets/csharp/api/system.xml.linq/xnode/readfrom/readfrom.csproj b/samples/snippets/csharp/api/system.xml.linq/xnode/readfrom/readfrom.csproj
new file mode 100644
index 00000000000..0d182e78911
--- /dev/null
+++ b/samples/snippets/csharp/api/system.xml.linq/xnode/readfrom/readfrom.csproj
@@ -0,0 +1,14 @@
+
+
+
+ Exe
+ netcoreapp2.2;net472
+
+
+
+
+ PreserveNewest
+
+
+
+
\ No newline at end of file
diff --git a/samples/snippets/csharp/api/system.xml/xmlexception/Program.cs b/samples/snippets/csharp/api/system.xml/xmlexception/Program.cs
new file mode 100644
index 00000000000..2ac334b9909
--- /dev/null
+++ b/samples/snippets/csharp/api/system.xml/xmlexception/Program.cs
@@ -0,0 +1,13 @@
+try {
+ XElement contacts = XElement.Parse(
+ @"
+
+ Jim Wilson
+
+ ");
+ Console.WriteLine(contacts);
+}
+catch (System.Xml.XmlException e)
+{
+ Console.WriteLine(e.Message);
+}
diff --git a/samples/snippets/csharp/api/system/datetimeoffset/parseexact/parseexact-iso8601-2.cs b/samples/snippets/csharp/api/system/datetimeoffset/parseexact/parseexact-iso8601-2.cs
new file mode 100644
index 00000000000..c67e4adc94e
--- /dev/null
+++ b/samples/snippets/csharp/api/system/datetimeoffset/parseexact/parseexact-iso8601-2.cs
@@ -0,0 +1,94 @@
+using System;
+using System.Globalization;
+
+public class Example
+{
+ public static void Main()
+ {
+ string[] dateStrings = { "2018-08-18T12:45:16.0000000Z",
+ "2018/08/18T12:45:16.0000000Z",
+ "2018-18-08T12:45:16.0000000Z",
+ "2018-08-18T12:45:16.0000000",
+ " 2018-08-18T12:45:16.0000000Z ",
+ "2018-08-18T12:45:16.0000000+02:00",
+ "2018-08-18T12:45:16.0000000-07:00" };
+
+ ParseWithISO8601(dateStrings, DateTimeStyles.None);
+ Console.WriteLine("\n-----\n");
+ ParseWithISO8601(dateStrings, DateTimeStyles.AllowWhiteSpaces);
+ Console.WriteLine("\n-----\n");
+ ParseWithISO8601(dateStrings, DateTimeStyles.AdjustToUniversal);
+ Console.WriteLine("\n-----\n");
+ ParseWithISO8601(dateStrings, DateTimeStyles.AssumeLocal);
+ Console.WriteLine("\n-----\n");
+ ParseWithISO8601(dateStrings, DateTimeStyles.AssumeUniversal); }
+
+ private static void ParseWithISO8601(string[] dateStrings, DateTimeStyles styles)
+ {
+ Console.WriteLine($"Parsing with {styles}:");
+ foreach (var dateString in dateStrings)
+ {
+ try {
+ var date = DateTimeOffset.ParseExact(dateString, "O", null, styles);
+ Console.WriteLine($" {dateString,-35} --> {date:yyyy-MM-dd HH:mm:ss.FF zzz}");
+ }
+ catch (FormatException)
+ {
+ Console.WriteLine($" FormatException: Unable to convert '{dateString}'");
+ }
+ }
+ }
+}
+// The example displays the following output:
+// Parsing with None:
+// 2018-08-18T12:45:16.0000000Z --> 2018-08-18 12:45:16 +00:00
+// FormatException: Unable to convert '2018/08/18T12:45:16.0000000Z'
+// FormatException: Unable to convert '2018-18-08T12:45:16.0000000Z'
+// 2018-08-18T12:45:16.0000000 --> 2018-08-18 12:45:16 -07:00
+// FormatException: Unable to convert ' 2018-08-18T12:45:16.0000000Z '
+// 2018-08-18T12:45:16.0000000+02:00 --> 2018-08-18 12:45:16 +02:00
+// 2018-08-18T12:45:16.0000000-07:00 --> 2018-08-18 12:45:16 -07:00
+//
+// -----
+//
+// Parsing with AllowWhiteSpaces:
+// 2018-08-18T12:45:16.0000000Z --> 2018-08-18 12:45:16 +00:00
+// FormatException: Unable to convert '2018/08/18T12:45:16.0000000Z'
+// FormatException: Unable to convert '2018-18-08T12:45:16.0000000Z'
+// 2018-08-18T12:45:16.0000000 --> 2018-08-18 12:45:16 -07:00
+// 2018-08-18T12:45:16.0000000Z --> 2018-08-18 12:45:16 +00:00
+// 2018-08-18T12:45:16.0000000+02:00 --> 2018-08-18 12:45:16 +02:00
+// 2018-08-18T12:45:16.0000000-07:00 --> 2018-08-18 12:45:16 -07:00
+//
+// -----
+//
+// Parsing with AdjustToUniversal:
+// 2018-08-18T12:45:16.0000000Z --> 2018-08-18 12:45:16 +00:00
+// FormatException: Unable to convert '2018/08/18T12:45:16.0000000Z'
+// FormatException: Unable to convert '2018-18-08T12:45:16.0000000Z'
+// 2018-08-18T12:45:16.0000000 --> 2018-08-18 19:45:16 +00:00
+// FormatException: Unable to convert ' 2018-08-18T12:45:16.0000000Z '
+// 2018-08-18T12:45:16.0000000+02:00 --> 2018-08-18 10:45:16 +00:00
+// 2018-08-18T12:45:16.0000000-07:00 --> 2018-08-18 19:45:16 +00:00
+//
+// -----
+//
+// Parsing with AssumeLocal:
+// 2018-08-18T12:45:16.0000000Z --> 2018-08-18 12:45:16 +00:00
+// FormatException: Unable to convert '2018/08/18T12:45:16.0000000Z'
+// FormatException: Unable to convert '2018-18-08T12:45:16.0000000Z'
+// 2018-08-18T12:45:16.0000000 --> 2018-08-18 12:45:16 -07:00
+// FormatException: Unable to convert ' 2018-08-18T12:45:16.0000000Z '
+// 2018-08-18T12:45:16.0000000+02:00 --> 2018-08-18 12:45:16 +02:00
+// 2018-08-18T12:45:16.0000000-07:00 --> 2018-08-18 12:45:16 -07:00
+//
+// -----
+//
+// Parsing with AssumeUniversal:
+// 2018-08-18T12:45:16.0000000Z --> 2018-08-18 12:45:16 +00:00
+// FormatException: Unable to convert '2018/08/18T12:45:16.0000000Z'
+// FormatException: Unable to convert '2018-18-08T12:45:16.0000000Z'
+// 2018-08-18T12:45:16.0000000 --> 2018-08-18 12:45:16 +00:00
+// FormatException: Unable to convert ' 2018-08-18T12:45:16.0000000Z '
+// 2018-08-18T12:45:16.0000000+02:00 --> 2018-08-18 12:45:16 +02:00
+// 2018-08-18T12:45:16.0000000-07:00 --> 2018-08-18 12:45:16 -07:00
\ No newline at end of file
diff --git a/samples/snippets/csharp/api/system/datetimeoffset/parseexact/parseexact-iso8601.cs b/samples/snippets/csharp/api/system/datetimeoffset/parseexact/parseexact-iso8601.cs
new file mode 100644
index 00000000000..b90538983b6
--- /dev/null
+++ b/samples/snippets/csharp/api/system/datetimeoffset/parseexact/parseexact-iso8601.cs
@@ -0,0 +1,33 @@
+using System;
+
+public class Example
+{
+ public static void Main()
+ {
+ string[] dateStrings = { "2018-08-18T12:45:16.0000000Z",
+ "2018/08/18T12:45:16.0000000Z",
+ "2018-18-08T12:45:16.0000000Z",
+ " 2018-08-18T12:45:16.0000000Z ",
+ "2018-08-18T12:45:16.0000000+02:00",
+ "2018-08-18T12:45:16.0000000-07:00" };
+
+ foreach (var dateString in dateStrings)
+ {
+ try {
+ var date = DateTimeOffset.ParseExact(dateString, "O", null);
+ Console.WriteLine($"{dateString,-35} --> {date:yyyy-MM-dd HH:mm:ss.FF zzz}");
+ }
+ catch (FormatException)
+ {
+ Console.WriteLine($"FormatException: Unable to convert '{dateString}'");
+ }
+ }
+ }
+}
+// The example displays the following output:
+// 2018-08-18T12:45:16.0000000Z --> 2018-08-18 12:45:16 +00:00
+// FormatException: Unable to convert '2018/08/18T12:45:16.0000000Z'
+// FormatException: Unable to convert '2018-18-08T12:45:16.0000000Z'
+// FormatException: Unable to convert ' 2018-08-18T12:45:16.0000000Z '
+// 2018-08-18T12:45:16.0000000+02:00 --> 2018-08-18 12:45:16 +02:00
+// 2018-08-18T12:45:16.0000000-07:00 --> 2018-08-18 12:45:16 -07:00
diff --git a/samples/snippets/csharp/api/system/datetimeoffset/tryparseexact/tryparseexacto8601-2.cs b/samples/snippets/csharp/api/system/datetimeoffset/tryparseexact/tryparseexacto8601-2.cs
new file mode 100644
index 00000000000..202381a1e5f
--- /dev/null
+++ b/samples/snippets/csharp/api/system/datetimeoffset/tryparseexact/tryparseexacto8601-2.cs
@@ -0,0 +1,95 @@
+using System;
+using System.Globalization;
+
+public class Example
+{
+ public static void Main()
+ {
+ string[] dateStrings = { "2018-08-18T12:45:16.0000000Z",
+ "2018/08/18T12:45:16.0000000Z",
+ "2018-18-08T12:45:16.0000000Z",
+ "2018-08-18T12:45:16.0000000",
+ " 2018-08-18T12:45:16.0000000Z ",
+ "2018-08-18T12:45:16.0000000+02:00",
+ "2018-08-18T12:45:16.0000000-07:00" };
+
+ ParseWithISO8601(dateStrings, DateTimeStyles.None);
+ Console.WriteLine("\n-----\n");
+ ParseWithISO8601(dateStrings, DateTimeStyles.AllowWhiteSpaces);
+ Console.WriteLine("\n-----\n");
+ ParseWithISO8601(dateStrings, DateTimeStyles.AdjustToUniversal);
+ Console.WriteLine("\n-----\n");
+ ParseWithISO8601(dateStrings, DateTimeStyles.AssumeLocal);
+ Console.WriteLine("\n-----\n");
+ ParseWithISO8601(dateStrings, DateTimeStyles.AssumeUniversal); }
+
+ private static void ParseWithISO8601(string[] dateStrings, DateTimeStyles styles)
+ {
+ Console.WriteLine($"Parsing with {styles}:");
+ DateTimeOffset date;
+ foreach (var dateString in dateStrings)
+ {
+ if (DateTimeOffset.TryParseExact(dateString, "O", null, styles, out date))
+ {
+ Console.WriteLine($" {dateString,-35} --> {date:yyyy-MM-dd HH:mm:ss.FF zzz}");
+ }
+ else
+ {
+ Console.WriteLine($" Unable to convert '{dateString}'");
+ }
+ }
+ }
+}
+// The example displays the following output:
+// Parsing with None:
+// 2018-08-18T12:45:16.0000000Z --> 2018-08-18 12:45:16 +00:00
+// Unable to convert '2018/08/18T12:45:16.0000000Z'
+// Unable to convert '2018-18-08T12:45:16.0000000Z'
+// 2018-08-18T12:45:16.0000000 --> 2018-08-18 12:45:16 -07:00
+// Unable to convert ' 2018-08-18T12:45:16.0000000Z '
+// 2018-08-18T12:45:16.0000000+02:00 --> 2018-08-18 12:45:16 +02:00
+// 2018-08-18T12:45:16.0000000-07:00 --> 2018-08-18 12:45:16 -07:00
+//
+// -----
+//
+// Parsing with AllowWhiteSpaces:
+// 2018-08-18T12:45:16.0000000Z --> 2018-08-18 12:45:16 +00:00
+// Unable to convert '2018/08/18T12:45:16.0000000Z'
+// Unable to convert '2018-18-08T12:45:16.0000000Z'
+// 2018-08-18T12:45:16.0000000 --> 2018-08-18 12:45:16 -07:00
+// 2018-08-18T12:45:16.0000000Z --> 2018-08-18 12:45:16 +00:00
+// 2018-08-18T12:45:16.0000000+02:00 --> 2018-08-18 12:45:16 +02:00
+// 2018-08-18T12:45:16.0000000-07:00 --> 2018-08-18 12:45:16 -07:00
+//
+// -----
+//
+// Parsing with AdjustToUniversal:
+// 2018-08-18T12:45:16.0000000Z --> 2018-08-18 12:45:16 +00:00
+// Unable to convert '2018/08/18T12:45:16.0000000Z'
+// Unable to convert '2018-18-08T12:45:16.0000000Z'
+// 2018-08-18T12:45:16.0000000 --> 2018-08-18 19:45:16 +00:00
+// Unable to convert ' 2018-08-18T12:45:16.0000000Z '
+// 2018-08-18T12:45:16.0000000+02:00 --> 2018-08-18 10:45:16 +00:00
+// 2018-08-18T12:45:16.0000000-07:00 --> 2018-08-18 19:45:16 +00:00
+//
+// -----
+//
+// Parsing with AssumeLocal:
+// 2018-08-18T12:45:16.0000000Z --> 2018-08-18 12:45:16 +00:00
+// Unable to convert '2018/08/18T12:45:16.0000000Z'
+// Unable to convert '2018-18-08T12:45:16.0000000Z'
+// 2018-08-18T12:45:16.0000000 --> 2018-08-18 12:45:16 -07:00
+// Unable to convert ' 2018-08-18T12:45:16.0000000Z '
+// 2018-08-18T12:45:16.0000000+02:00 --> 2018-08-18 12:45:16 +02:00
+// 2018-08-18T12:45:16.0000000-07:00 --> 2018-08-18 12:45:16 -07:00
+//
+// -----
+//
+// Parsing with AssumeUniversal:
+// 2018-08-18T12:45:16.0000000Z --> 2018-08-18 12:45:16 +00:00
+// Unable to convert '2018/08/18T12:45:16.0000000Z'
+// Unable to convert '2018-18-08T12:45:16.0000000Z'
+// 2018-08-18T12:45:16.0000000 --> 2018-08-18 12:45:16 +00:00
+// Unable to convert ' 2018-08-18T12:45:16.0000000Z '
+// 2018-08-18T12:45:16.0000000+02:00 --> 2018-08-18 12:45:16 +02:00
+// 2018-08-18T12:45:16.0000000-07:00 --> 2018-08-18 12:45:16 -07:00
diff --git a/samples/snippets/csharp/api/system/span.enumerator/nosync/Program.cs b/samples/snippets/csharp/api/system/span.enumerator/nosync/Program.cs
new file mode 100644
index 00000000000..226eaa05f05
--- /dev/null
+++ b/samples/snippets/csharp/api/system/span.enumerator/nosync/Program.cs
@@ -0,0 +1,41 @@
+using System;
+using System.Threading.Tasks;
+
+class Program
+{
+ private static readonly byte[] _array = new byte[5];
+
+ static void Main()
+ {
+ new Random(42).NextBytes(_array);
+ Span span = _array;
+
+ Task.Run( () => ClearContents() );
+
+ EnumerateSpan(span);
+ }
+
+ public static void ClearContents()
+ {
+ Task.Delay(20).Wait();
+ lock (_array)
+ {
+ Array.Clear(_array, 0, _array.Length);
+ }
+ }
+
+ public static void EnumerateSpan(Span span)
+ {
+ foreach (byte element in span)
+ {
+ Console.WriteLine(element);
+ Task.Delay(10).Wait();
+ }
+ }
+}
+// The example displays output like the following:
+// 62
+// 23
+// 186
+// 0
+// 0
\ No newline at end of file
diff --git a/samples/snippets/csharp/api/system/span.enumerator/nosync/synchronization.csproj b/samples/snippets/csharp/api/system/span.enumerator/nosync/synchronization.csproj
new file mode 100644
index 00000000000..01d5113289c
--- /dev/null
+++ b/samples/snippets/csharp/api/system/span.enumerator/nosync/synchronization.csproj
@@ -0,0 +1,8 @@
+
+
+
+ Exe
+ netcoreapp2.2
+
+
+
diff --git a/samples/snippets/csharp/api/system/span.enumerator/sync/Program.cs b/samples/snippets/csharp/api/system/span.enumerator/sync/Program.cs
new file mode 100644
index 00000000000..f04d0362f44
--- /dev/null
+++ b/samples/snippets/csharp/api/system/span.enumerator/sync/Program.cs
@@ -0,0 +1,46 @@
+using System;
+using System.Threading.Tasks;
+
+class Program
+{
+ private static readonly byte[] _array = new byte[5];
+
+ static void Main()
+ {
+ new Random(42).NextBytes(_array);
+ Span span = _array;
+
+ Task.Run( () => ClearContents() );
+
+ EnumerateSpan(span);
+ }
+
+ public static void ClearContents()
+ {
+ Task.Delay(20).Wait();
+ lock (_array)
+ {
+ Array.Clear(_array, 0, _array.Length);
+ }
+ }
+
+ //
+ public static void EnumerateSpan(Span span)
+ {
+ lock (_array)
+ {
+ foreach (byte element in span)
+ {
+ Console.WriteLine(element);
+ Task.Delay(10).Wait();
+ }
+ }
+ }
+ // The example displays the following output:
+ // 62
+ // 23
+ // 186
+ // 150
+ // 174
+ //
+}
diff --git a/samples/snippets/csharp/api/system/span.enumerator/sync/synchronization.csproj b/samples/snippets/csharp/api/system/span.enumerator/sync/synchronization.csproj
new file mode 100644
index 00000000000..01d5113289c
--- /dev/null
+++ b/samples/snippets/csharp/api/system/span.enumerator/sync/synchronization.csproj
@@ -0,0 +1,8 @@
+
+
+
+ Exe
+ netcoreapp2.2
+
+
+
diff --git a/samples/snippets/csharp/api/system/span/program.cs b/samples/snippets/csharp/api/system/span/program.cs
new file mode 100644
index 00000000000..089f5b136a4
--- /dev/null
+++ b/samples/snippets/csharp/api/system/span/program.cs
@@ -0,0 +1,134 @@
+using System;
+using System.Runtime.InteropServices;
+using static Program2;
+
+class Program
+{
+ static void Main()
+ {
+ CreateSpanFromArray();
+ Console.WriteLine("-----");
+ CreateSpanFromNativeMemory();
+ Console.WriteLine("-----");
+ CreateSpanFromStack();
+ WorkWithSpans();
+ Console.WriteLine("-----");
+ Program2.WorkWithSpans();
+ }
+
+ private static void CreateSpanFromArray()
+ {
+ //
+ // Create a span over an array.
+ var array = new byte[100];
+ var arraySpan = new Span(array);
+
+ byte data = 0;
+ for (int ctr = 0; ctr < arraySpan.Length; ctr++)
+ arraySpan[ctr] = data++;
+
+ int arraySum = 0;
+ foreach (var value in array)
+ arraySum += value;
+
+ Console.WriteLine($"The sum is {arraySum}");
+ // Output: The sum is 4950
+ //
+ }
+
+ private static void CreateSpanFromNativeMemory()
+ {
+ //
+ // Create a span from native memory.
+ var native = Marshal.AllocHGlobal(100);
+ Span nativeSpan;
+ unsafe
+ {
+ nativeSpan = new Span(native.ToPointer(), 100);
+ }
+ byte data = 0;
+ for (int ctr = 0; ctr < nativeSpan.Length; ctr++)
+ nativeSpan[ctr] = data++;
+
+ int nativeSum = 0;
+ foreach (var value in nativeSpan)
+ nativeSum += value;
+
+ Console.WriteLine($"The sum is {nativeSum}");
+ Marshal.FreeHGlobal(native);
+ // Output: The sum is 4950
+ //
+ }
+
+ private static void CreateSpanFromStack()
+ {
+ //
+ // Create a span on the stack.
+ byte data = 0;
+ Span stackSpan = stackalloc byte[100];
+ for (int ctr = 0; ctr < stackSpan.Length; ctr++)
+ stackSpan[ctr] = data++;
+
+ int stackSum = 0;
+ foreach (var value in stackSpan)
+ stackSum += value;
+
+ Console.WriteLine($"The sum is {stackSum}");
+ // Output: The sum is 4950
+ //
+ }
+}
+
+public class Program2
+{
+ //
+ public static void WorkWithSpans()
+ {
+ // Create a span over an array.
+ var array = new byte[100];
+ var arraySpan = new Span(array);
+
+ InitializeSpan(arraySpan);
+ Console.WriteLine($"The sum is {ComputeSum(arraySpan):N0}");
+
+ // Create an array from native memory.
+ var native = Marshal.AllocHGlobal(100);
+ Span nativeSpan;
+ unsafe
+ {
+ nativeSpan = new Span(native.ToPointer(), 100);
+ }
+
+ InitializeSpan(nativeSpan);
+ Console.WriteLine($"The sum is {ComputeSum(nativeSpan):N0}");
+
+ Marshal.FreeHGlobal(native);
+
+ // Create a span on the stack.
+ Span stackSpan = stackalloc byte[100];
+
+ InitializeSpan(stackSpan);
+ Console.WriteLine($"The sum is {ComputeSum(stackSpan):N0}");
+ }
+
+ public static void InitializeSpan(Span span)
+ {
+ byte value = 0;
+ for (int ctr = 0; ctr < span.Length; ctr++)
+ span[ctr] = value++;
+ }
+
+ public static int ComputeSum(Span span)
+ {
+ int sum = 0;
+ foreach (var value in span)
+ sum += value;
+
+ return sum;
+ }
+ // The example displays the following output:
+ // The sum is 4,950
+ // The sum is 4,950
+ // The sum is 4,950
+ //
+}
diff --git a/samples/snippets/csharp/api/system/span/program.csproj b/samples/snippets/csharp/api/system/span/program.csproj
new file mode 100644
index 00000000000..4b505c6cf68
--- /dev/null
+++ b/samples/snippets/csharp/api/system/span/program.csproj
@@ -0,0 +1,9 @@
+
+
+
+ true
+ Exe
+ netcoreapp2.2
+ Latest
+
+
diff --git a/samples/snippets/csharp/api/system/span/slice/Program.cs b/samples/snippets/csharp/api/system/span/slice/Program.cs
new file mode 100644
index 00000000000..db3c4fae623
--- /dev/null
+++ b/samples/snippets/csharp/api/system/span/slice/Program.cs
@@ -0,0 +1,22 @@
+using System;
+
+namespace span
+{
+ class Program
+ {
+ static void Main(string[] args)
+ {
+ var array = new int[] { 2, 4, 6, 8, 10, 12, 14, 16, 18, 20 };
+ var slice = new Span(array, 2, 5);
+ for (int ctr = 0; ctr < slice.Length; ctr++)
+ slice[ctr] *= 2;
+
+ // Examine the original array values.
+ foreach (var value in array)
+ Console.Write($"{value} ");
+ Console.WriteLine();
+ }
+ }
+}
+// The example displays the following output:
+// 2 4 12 16 20 24 28 16 18 20
diff --git a/samples/snippets/csharp/api/system/span/slice/slice.csproj b/samples/snippets/csharp/api/system/span/slice/slice.csproj
new file mode 100644
index 00000000000..4b505c6cf68
--- /dev/null
+++ b/samples/snippets/csharp/api/system/span/slice/slice.csproj
@@ -0,0 +1,9 @@
+
+
+
+ true
+ Exe
+ netcoreapp2.2
+ Latest
+
+
diff --git a/samples/snippets/csharp/api/system/span/slice2/Program.cs b/samples/snippets/csharp/api/system/span/slice2/Program.cs
new file mode 100644
index 00000000000..2b3172ad4b3
--- /dev/null
+++ b/samples/snippets/csharp/api/system/span/slice2/Program.cs
@@ -0,0 +1,19 @@
+using System;
+
+class Program
+{
+ static void Main()
+ {
+ string contentLength = "Content-Length: 132";
+ var length = GetContentLength(contentLength.ToCharArray());
+ Console.WriteLine($"Content length: {length}");
+ }
+
+ private static int GetContentLength(ReadOnlySpan span)
+ {
+ var slice = span.Slice(16);
+ return int.Parse(slice);
+ }
+}
+// Output:
+// Content length: 132
diff --git a/samples/snippets/csharp/api/system/span/slice2/substring.csproj b/samples/snippets/csharp/api/system/span/slice2/substring.csproj
new file mode 100644
index 00000000000..01d5113289c
--- /dev/null
+++ b/samples/snippets/csharp/api/system/span/slice2/substring.csproj
@@ -0,0 +1,8 @@
+
+
+
+ Exe
+ netcoreapp2.2
+
+
+
diff --git a/samples/snippets/csharp/api/system/string/copy/Program.cs b/samples/snippets/csharp/api/system/string/copy/Program.cs
new file mode 100644
index 00000000000..7b06be7a349
--- /dev/null
+++ b/samples/snippets/csharp/api/system/string/copy/Program.cs
@@ -0,0 +1,81 @@
+using System;
+using System.Runtime.InteropServices;
+
+namespace copy
+{
+ class Program
+ {
+ static void Main()
+ {
+ PerformStringOperation();
+ Console.WriteLine("---");
+ UseMutableBuffer();
+ Console.WriteLine("---");
+ UseUnmanaged();
+ }
+
+ private static void PerformStringOperation()
+ {
+ //
+ var original = "This is a sentence. This is a second sentence.";
+ var sentence1 = original.Substring(0, original.IndexOf(".") + 1);
+ Console.WriteLine(original);
+ Console.WriteLine(sentence1);
+ // The example displays the following output:
+ // This is a sentence. This is a second sentence.
+ // This is a sentence.
+ //
+ }
+
+ //
+ private static void UseMutableBuffer()
+ {
+ var original = "This is a sentence. This is a second sentence.";
+ var chars = original.ToCharArray();
+ var span = new Span(chars);
+ var slice = span.Slice(span.IndexOf('.'), 3);
+ slice = MergeSentence(slice);
+ Console.WriteLine($"Original string: {original}");
+ Console.WriteLine($"Modified string: {span.ToString()}");
+
+ static Span MergeSentence(Span span)
+ {
+ if (span.Length == 0) return Span.Empty;
+
+ span[0] = ';';
+ span[2] = Char.ToLower(span[2]);
+ return span;
+ }
+ }
+ // The example displays the following output:
+ // Original string: This is a sentence. This is a second sentence.
+ // Modified string: This is a sentence; this is a second sentence.
+ //
+
+ //
+ private static void UseUnmanaged()
+ {
+ var original = "This is a single sentence.";
+ var len = original.Length;
+ var ptr = Marshal.StringToHGlobalUni(original);
+ string result;
+ unsafe
+ {
+ char *ch = (char *) ptr.ToPointer();
+ while (len-- > 0)
+ {
+ char c = Convert.ToChar(Convert.ToUInt16(*ch) + 1);
+ *ch++ = c;
+ }
+ result = Marshal.PtrToStringUni(ptr);
+ Marshal.FreeHGlobal(ptr);
+ }
+ Console.WriteLine($"Original string: {original}");
+ Console.WriteLine($"String from interop: '{result}'");
+ }
+ // The example displays the following output:
+ // Original string: This is a single sentence.
+ // String from interop: 'Uijt!jt!b!tjohmf!tfoufodf/'
+ //
+ }
+}
diff --git a/samples/snippets/csharp/api/system/string/copy/copy.csproj b/samples/snippets/csharp/api/system/string/copy/copy.csproj
new file mode 100644
index 00000000000..68ca9a06732
--- /dev/null
+++ b/samples/snippets/csharp/api/system/string/copy/copy.csproj
@@ -0,0 +1,10 @@
+
+
+
+ Exe
+ netcoreapp3.0
+ 8.0
+ True
+
+
+
diff --git a/samples/snippets/visualbasic/VS_Snippets_Atlas/System.Web.Script.Serialization.TypeResolver/VB/Default.aspx b/samples/snippets/visualbasic/VS_Snippets_Atlas/System.Web.Script.Serialization.TypeResolver/VB/Default.aspx
new file mode 100644
index 00000000000..abbfd058766
--- /dev/null
+++ b/samples/snippets/visualbasic/VS_Snippets_Atlas/System.Web.Script.Serialization.TypeResolver/VB/Default.aspx
@@ -0,0 +1,67 @@
+
+<%@ Page Language="VB" %>
+<%@ Import Namespace="System.Web.Script.Serialization" %>
+<%@ Import Namespace="System.Web.Script.Serialization.TypeResolver.VB" %>
+
+
+
+
+
+
+
+ Type Resolvers
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/samples/snippets/visualbasic/VS_Snippets_Atlas/System.Web.Script.Serialization/VB/Default.aspx b/samples/snippets/visualbasic/VS_Snippets_Atlas/System.Web.Script.Serialization/VB/Default.aspx
new file mode 100644
index 00000000000..2a2d94eb9de
--- /dev/null
+++ b/samples/snippets/visualbasic/VS_Snippets_Atlas/System.Web.Script.Serialization/VB/Default.aspx
@@ -0,0 +1,179 @@
+
+<%@ Page Language="VB" %>
+<%@ Import Namespace="System.Web.Script.Serialization" %>
+
+
+
+
+
+
+
+ Save/Recover state
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/samples/snippets/visualbasic/VS_Snippets_Atlas/System.Web.UI.UpdatePanel.CreateContentTemplateContainer/VB/UpdatePanelCreateContentTemplateContainerVB.aspx b/samples/snippets/visualbasic/VS_Snippets_Atlas/System.Web.UI.UpdatePanel.CreateContentTemplateContainer/VB/UpdatePanelCreateContentTemplateContainerVB.aspx
new file mode 100644
index 00000000000..68a350afb73
--- /dev/null
+++ b/samples/snippets/visualbasic/VS_Snippets_Atlas/System.Web.UI.UpdatePanel.CreateContentTemplateContainer/VB/UpdatePanelCreateContentTemplateContainerVB.aspx
@@ -0,0 +1,29 @@
+
+<%@ Page Language="VB" %>
+<%@ Register Namespace="SamplesCS" TagPrefix="Samples" %>
+
+
+
+
+ CreateContentTemplateContainer Example
+
+
+
+
+
+
diff --git a/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.Char [Type Level]/VB/charstructure.vb b/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.Char [Type Level]/VB/charstructure.vb
new file mode 100644
index 00000000000..e0b44119f2f
--- /dev/null
+++ b/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.Char [Type Level]/VB/charstructure.vb
@@ -0,0 +1,32 @@
+'
+Module CharStructure
+
+ Public Sub Main()
+
+ Dim chA As Char
+ chA = "A"c
+ Dim ch1 As Char
+ ch1 = "1"c
+ Dim str As String
+ str = "test string"
+
+ Console.WriteLine(chA.CompareTo("B"c)) ' Output: "-1" (meaning 'A' is 1 less than 'B')
+ Console.WriteLine(chA.Equals("A"c)) ' Output: "True"
+ Console.WriteLine(Char.GetNumericValue(ch1)) ' Output: "1"
+ Console.WriteLine(Char.IsControl(Chr(9))) ' Output: "True"
+ Console.WriteLine(Char.IsDigit(ch1)) ' Output: "True"
+ Console.WriteLine(Char.IsLetter(","c)) ' Output: "False"
+ Console.WriteLine(Char.IsLower("u"c)) ' Output: "True"
+ Console.WriteLine(Char.IsNumber(ch1)) ' Output: "True"
+ Console.WriteLine(Char.IsPunctuation("."c)) ' Output: "True"
+ Console.WriteLine(Char.IsSeparator(str, 4)) ' Output: "True"
+ Console.WriteLine(Char.IsSymbol("+"c)) ' Output: "True"
+ Console.WriteLine(Char.IsWhiteSpace(str, 4)) ' Output: "True"
+ Console.WriteLine(Char.Parse("S")) ' Output: "S"
+ Console.WriteLine(Char.ToLower("M"c)) ' Output: "m"
+ Console.WriteLine("x"c.ToString()) ' Output: "x"
+
+ End Sub
+
+End Module
+'
diff --git a/samples/snippets/visualbasic/api/system.collections.concurrent/concurrentbag/concbag.vb b/samples/snippets/visualbasic/api/system.collections.concurrent/concurrentbag/concbag.vb
new file mode 100644
index 00000000000..e580adc482b
--- /dev/null
+++ b/samples/snippets/visualbasic/api/system.collections.concurrent/concurrentbag/concbag.vb
@@ -0,0 +1,47 @@
+'
+Imports System.Collections.Concurrent
+
+Module ConcurrentBagDemo
+ ' Demonstrates:
+ ' ConcurrentBag.Add()
+ ' ConcurrentBag.IsEmpty
+ ' ConcurrentBag.TryTake()
+ ' ConcurrentBag.TryPeek()
+ Sub Main()
+ ' Add to ConcurrentBag concurrently
+ Dim cb As New ConcurrentBag(Of Integer)()
+ Dim bagAddTasks As New List(Of Task)()
+ For i = 1 To 500
+ Dim numberToAdd As Integer = i
+ bagAddTasks.Add(Task.Run(Sub() cb.Add(numberToAdd)))
+ Next
+
+ ' Wait for all tasks to complete
+ Task.WaitAll(bagAddTasks.ToArray())
+
+ ' Consume the items in the bag
+ Dim bagConsumeTasks As New List(Of Task)()
+ Dim itemsInBag As Integer = 0
+ While Not cb.IsEmpty
+ bagConsumeTasks.Add(Task.Run(Sub()
+ Dim item As Integer
+ If cb.TryTake(item) Then
+ Console.WriteLine(item)
+ itemsInBag = itemsInBag + 1
+ End If
+ End Sub))
+ End While
+
+ Task.WaitAll(bagConsumeTasks.ToArray())
+
+ Console.WriteLine($"There were {itemsInBag} items in the bag")
+
+ ' Checks the bag for an item
+ ' The bag should be empty and this should not print anything
+ Dim unexpectedItem As Integer
+ If cb.TryPeek(unexpectedItem) Then
+ Console.WriteLine("Found an item in the bag when it should be empty")
+ End If
+ End Sub
+End Module
+'
\ No newline at end of file
diff --git a/samples/snippets/visualbasic/api/system.collections/icomparer/reverse.vb b/samples/snippets/visualbasic/api/system.collections/icomparer/reverse.vb
new file mode 100644
index 00000000000..90b51d1cf6c
--- /dev/null
+++ b/samples/snippets/visualbasic/api/system.collections/icomparer/reverse.vb
@@ -0,0 +1,74 @@
+Imports System.Collections
+
+Public Class Example
+ Public Class ReverserClass : Implements IComparer
+ ' Call CaseInsensitiveComparer.Compare with the parameters reversed.
+ Public Function Compare(ByVal x As Object, ByVal y As Object) As Integer _
+ Implements IComparer.Compare
+ Return New CaseInsensitiveComparer().Compare(y, x)
+ End Function
+ End Class
+
+ Public Shared Sub Main()
+ ' Initialize a string array.
+ Dim words() As String = { "The", "quick", "brown", "fox", "jumps", "over",
+ "the", "lazy", "dog" }
+
+ ' Display the array values.
+ Console.WriteLine("The array initially contains the following values:")
+ PrintIndexAndValues(words)
+
+ ' Sort the array values of the ArrayList using the default comparer.
+ Array.Sort(words)
+ Console.WriteLine("After sorting with the default comparer:")
+ PrintIndexAndValues(words)
+
+ ' Sort the array values using the reverse case-insensitive comparer.
+ Array.Sort(words, new ReverserClass())
+ Console.WriteLine("After sorting with the reverse case-insensitive comparer:")
+ PrintIndexAndValues(words)
+ End Sub
+
+ Public Shared Sub PrintIndexAndValues(list As IEnumerable)
+ Dim i As Integer = 0
+ For Each item In list
+ Console.WriteLine($" [{i}]: {item}")
+ i += 1
+ Next
+ Console.WriteLine()
+ End Sub
+End Class
+' The example displays the following output:
+' The array initially contains the following values:
+' [0]: The
+' [1]: quick
+' [2]: brown
+' [3]: fox
+' [4]: jumps
+' [5]: over
+' [6]: the
+' [7]: lazy
+' [8]: dog
+'
+' After sorting with the default comparer:
+' [0]: brown
+' [1]: dog
+' [2]: fox
+' [3]: jumps
+' [4]: lazy
+' [5]: over
+' [6]: quick
+' [7]: the
+' [8]: The
+'
+' After sorting with the reverse case-insensitive comparer:
+' [0]: the
+' [1]: The
+' [2]: quick
+' [3]: over
+' [4]: lazy
+' [5]: jumps
+' [6]: fox
+' [7]: dog
+' [8]: brown
+
diff --git a/samples/snippets/visualbasic/api/system.diagnostics/process/standarderror/stderror-sync.vb b/samples/snippets/visualbasic/api/system.diagnostics/process/standarderror/stderror-sync.vb
new file mode 100644
index 00000000000..1930cf16d24
--- /dev/null
+++ b/samples/snippets/visualbasic/api/system.diagnostics/process/standarderror/stderror-sync.vb
@@ -0,0 +1,20 @@
+Imports System.Diagnostics
+
+Public Module Example
+ Public Sub Main()
+ Dim p As New Process()
+ p.StartInfo.UseShellExecute = False
+ p.StartInfo.RedirectStandardError = True
+ p.StartInfo.FileName = "Write500Lines.exe"
+ p.Start()
+
+ ' To avoid deadlocks, always read the output stream first and then wait.
+ Dim output As String = p.StandardError.ReadToEnd()
+ p.WaitForExit()
+
+ Console.WriteLine($"{vbCrLf}Error stream: {output}")
+ End Sub
+End Module
+' The end of the output produced by the example includes the following:
+' Error stream:
+' Successfully wrote 500 lines.
diff --git a/samples/snippets/visualbasic/api/system.diagnostics/process/standardoutput/Write500Lines.vb b/samples/snippets/visualbasic/api/system.diagnostics/process/standardoutput/Write500Lines.vb
new file mode 100644
index 00000000000..cd0ceb0bc90
--- /dev/null
+++ b/samples/snippets/visualbasic/api/system.diagnostics/process/standardoutput/Write500Lines.vb
@@ -0,0 +1,18 @@
+Imports System.IO
+
+Public Module Example
+ Public Sub Main()
+ For ctr As Integer = 0 To 499
+ Console.WriteLine($"Line {ctr + 1} of 500 written: {ctr + 1/500.0:P2}")
+ Next
+
+ Console.Error.WriteLine($"{vbCrLf}Successfully wrote 500 lines.{vbCrLf}")
+ End Sub
+End Module
+' The example displays the following output:
+' The last 50 characters in the output stream are:
+' ' 49,800.20%
+' Line 500 of 500 written: 49,900.20%
+'
+'
+' Error stream: Successfully wrote 500 lines.
\ No newline at end of file
diff --git a/samples/snippets/visualbasic/api/system.diagnostics/process/standardoutput/stdoutput-async.vb b/samples/snippets/visualbasic/api/system.diagnostics/process/standardoutput/stdoutput-async.vb
new file mode 100644
index 00000000000..a24d41e3472
--- /dev/null
+++ b/samples/snippets/visualbasic/api/system.diagnostics/process/standardoutput/stdoutput-async.vb
@@ -0,0 +1,29 @@
+Imports System.Diagnostics
+
+Public Module Example
+ Public Sub Main()
+ Dim p As New Process()
+ p.StartInfo.UseShellExecute = False
+ p.StartInfo.RedirectStandardOutput = True
+ Dim eOut As String = Nothing
+ p.StartInfo.RedirectStandardError = True
+ AddHandler p.ErrorDataReceived, Sub(sender, e) eOut += e.Data
+ p.StartInfo.FileName = "Write500Lines.exe"
+ p.Start()
+
+ ' To avoid deadlocks, use an asynchronous read operation on at least one of the streams.
+ p.BeginErrorReadLine()
+ Dim output As String = p.StandardOutput.ReadToEnd()
+ p.WaitForExit()
+
+ Console.WriteLine($"The last 50 characters in the output stream are:{vbCrLf}'{output.Substring(output.Length - 50)}'")
+ Console.WriteLine($"{vbCrLf}Error stream: {eOut}")
+ End Sub
+End Module
+' The example displays the following output:
+' The last 50 characters in the output stream are:
+' ' 49,800.20%
+' Line 500 of 500 written: 49,900.20%
+' '
+'
+' Error stream: Successfully wrote 500 lines.
\ No newline at end of file
diff --git a/samples/snippets/visualbasic/api/system.diagnostics/process/standardoutput/stdoutput-sync.vb b/samples/snippets/visualbasic/api/system.diagnostics/process/standardoutput/stdoutput-sync.vb
new file mode 100644
index 00000000000..2b21ae10a17
--- /dev/null
+++ b/samples/snippets/visualbasic/api/system.diagnostics/process/standardoutput/stdoutput-sync.vb
@@ -0,0 +1,24 @@
+Imports System.Diagnostics'
+
+Public Module Example
+ Public Sub Main()
+ Dim p As New Process()
+ p.StartInfo.UseShellExecute = False
+ p.StartInfo.RedirectStandardOutput = True
+ p.StartInfo.FileName = "Write500Lines.exe"
+ p.Start()
+
+ ' To avoid deadlocks, always read the output stream first and then wait.
+ Dim output As String = p.StandardOutput.ReadToEnd()
+ p.WaitForExit()
+
+ Console.WriteLine($"The last 50 characters in the output stream are:\n'{output.Substring(output.Length - 50)}'")
+ End Sub
+End Module
+' The example displays the following output:
+' Successfully wrote 500 lines.
+'
+' The last 50 characters in the output stream are:
+' ' 49,800.20%
+' Line 500 of 500 written: 49,900.20%
+' '
\ No newline at end of file
diff --git a/samples/snippets/visualbasic/api/system.globalization/japanesecalendar/todatetime/Program.vb b/samples/snippets/visualbasic/api/system.globalization/japanesecalendar/todatetime/Program.vb
new file mode 100644
index 00000000000..62c7dd39040
--- /dev/null
+++ b/samples/snippets/visualbasic/api/system.globalization/japanesecalendar/todatetime/Program.vb
@@ -0,0 +1,30 @@
+Imports System.Globalization
+
+Module Program
+ Dim cal As Calendar
+ Dim jaJp As CultureInfo
+
+ Public Sub Main()
+ cal = New JapaneseCalendar()
+ jaJp = New CultureInfo("ja-JP")
+ jaJp.DateTimeFormat.Calendar = cal
+ Dim date1 = cal.ToDateTime(2,1,1,0,0,0,0,JapaneseCalendar.CurrentEra)
+ Console.WriteLine($"Japanese calendar date: {date1.ToString("D", jaJp)}, " +
+ $"Gregorian calendar date: {date1.ToString("D", CultureInfo.InvariantCulture)}")
+
+ Dim date2 = cal.ToDateTime(6,11,7,0,0,0,0,GetEraIndex("大正"))
+ Console.WriteLine($"Japanese calendar date: {date2.ToString("D", jaJp)}, " +
+ $"Gregorian calendar date: {date2.ToString("D", CultureInfo.InvariantCulture)}")
+ End Sub
+
+ Private Function GetEraIndex(eraName As String) As Integer
+ For Each ctr in cal.Eras
+ If jaJp.DateTimeFormat.GetEraName(ctr) = eraName Then Return ctr
+ Next
+
+ Return 0
+ End Function
+End Module
+' The example displays the following output:
+' Japanese calendar date: 平成2年1月1日, Gregorian calendar date: Monday, 01 January 1990
+' Japanese calendar date: 大正6年11月7日, Gregorian calendar date: Wednesday, 07 November 1917
diff --git a/samples/snippets/visualbasic/api/system.globalization/japanesecalendar/todatetime/todatetime.vbproj b/samples/snippets/visualbasic/api/system.globalization/japanesecalendar/todatetime/todatetime.vbproj
new file mode 100644
index 00000000000..c8f37ffc990
--- /dev/null
+++ b/samples/snippets/visualbasic/api/system.globalization/japanesecalendar/todatetime/todatetime.vbproj
@@ -0,0 +1,9 @@
+
+
+
+ Exe
+ todatetime.vb
+ netcoreapp3.0
+
+
+
diff --git a/samples/snippets/visualbasic/api/system.io/path/IsPathRooted/Program.vb b/samples/snippets/visualbasic/api/system.io/path/IsPathRooted/Program.vb
new file mode 100644
index 00000000000..90892f4e9f0
--- /dev/null
+++ b/samples/snippets/visualbasic/api/system.io/path/IsPathRooted/Program.vb
@@ -0,0 +1,37 @@
+Imports System.IO
+
+Module Program
+ Public Sub Main()
+ Dim relative1 As String = "C:Documents"
+ ShowPathInfo(relative1)
+
+ Dim relative2 As String = "C:Documents"
+ ShowPathInfo(relative2)
+
+ Dim absolute As String = "C:/Documents"
+ ShowPathInfo(absolute)
+ End Sub
+
+ Private Sub ShowPathInfo(filepath As String)
+ Console.WriteLine($"Path: {filepath}")
+ Console.WriteLine($" Rooted: {Path.IsPathRooted(filepath)}")
+ Console.WriteLine($" Fully qualified: {Path.IsPathFullyQualified(filepath)}")
+ Console.WriteLine($" Full path: {Path.GetFullPath(filepath)}")
+ Console.WriteLine()
+ End Sub
+End Module
+' The example displays the following output when run on a Windows system:
+' Path: C:Documents
+' Rooted: True
+' Fully qualified: False
+' Full path: c:\Users\user1\Documents\projects\path\ispathrooted\Documents
+'
+' Path: /Documents
+' Rooted: True
+' Fully qualified: False
+' Full path: c:\Documents
+'
+' Path: C:/Documents
+' Rooted: True
+' Fully qualified: True
+' Full path: C:\Documents
\ No newline at end of file
diff --git a/samples/snippets/visualbasic/api/system.io/path/IsPathRooted/ispathrooted.vb.vbproj b/samples/snippets/visualbasic/api/system.io/path/IsPathRooted/ispathrooted.vb.vbproj
new file mode 100644
index 00000000000..b2ac2d04070
--- /dev/null
+++ b/samples/snippets/visualbasic/api/system.io/path/IsPathRooted/ispathrooted.vb.vbproj
@@ -0,0 +1,9 @@
+
+
+
+ Exe
+ ispathrooted.vb
+ netcoreapp2.2
+
+
+
diff --git a/samples/snippets/visualbasic/api/system.io/path/combine/Program.vb b/samples/snippets/visualbasic/api/system.io/path/combine/Program.vb
new file mode 100644
index 00000000000..f5488393fb6
--- /dev/null
+++ b/samples/snippets/visualbasic/api/system.io/path/combine/Program.vb
@@ -0,0 +1,78 @@
+Imports System.IO
+
+Module Program
+ Public Sub Main()
+ Console.WriteLine("Path.Combine(String())")
+ Combine1()
+ Console.WriteLine()
+ Console.WriteLine("Path.Combine(String,String)")
+ Combine2()
+ Console.WriteLine()
+ Console.WriteLine("Path.Combine(String,String,String)")
+ Combine3()
+ Console.WriteLine()
+ Console.WriteLine("Path.Combine(String,String,String,String)")
+ Combine4()
+ End Sub
+
+ Private Sub Combine1()
+ '
+ Dim paths As String() = { "d:\archives", "2001", "media", "images" }
+ Dim fullPath As String = Path.Combine(paths)
+ Console.WriteLine(fullPath)
+
+ paths = { "d:\archives\", "2001\", "media", "images" }
+ fullPath = Path.Combine(paths)
+ Console.WriteLine(fullPath)
+
+ paths = { "d:/archives/", "2001/", "media", "images" }
+ fullPath = Path.Combine(paths)
+ Console.WriteLine(fullPath)
+ ' The example displays the following output if run on a Windows system:
+ ' d:\archives\2001\media\images
+ ' d:\archives\2001\media\images
+ ' d:/archives/2001/media\images
+ '
+ ' The example displays the following output if run on a Linux system:
+ ' d:\archives/2001/media/images
+ ' d:\archives\/2001\/media/images
+ ' d:/archives/2001/media/images
+ '
+ End Sub
+
+ Private Sub Combine2()
+ '
+ Dim result = Path.Combine("C:\Pictures\", "Saved Pictures")
+ Console.WriteLine(result)
+ ' The example displays the following output if run on a Windows system:
+ ' C:\Pictures\Saved Pictures
+ '
+ ' The example displays the following output if run on a Unix-based system:
+ ' C:\Pictures\/Saved Pictures
+ '
+ End Sub
+
+ Private Sub Combine3()
+ '
+ Dim result = Path.Combine("C:\Pictures\", "Saved Pictures\", "2019")
+ Console.WriteLine(result)
+ ' The example displays the following output if run on a Windows system:
+ ' C:\Pictures\Saved Pictures\2019
+ '
+ ' The example displays the following output if run on a Unix-based system:
+ ' C:\Pictures\/Saved Pictures\/2019
+ '
+ End Sub
+
+ Private Sub Combine4()
+ '
+ Dim result = Path.Combine("C:\Pictures\", "Saved Pictures\", "2019\", "Jan\")
+ Console.WriteLine(result)
+ ' The example displays the following output if run on a Windows system:
+ ' C:\Pictures\Saved Pictures\2019\Jan\
+ '
+ ' The example displays the following output if run on a Unix-based system:
+ ' C:\Pictures\Saved Pictures\2019\Jan\
+ '
+ End Sub
+End Module
diff --git a/samples/snippets/visualbasic/api/system.io/path/combine/misc.vb.vbproj b/samples/snippets/visualbasic/api/system.io/path/combine/misc.vb.vbproj
new file mode 100644
index 00000000000..40824fcf85f
--- /dev/null
+++ b/samples/snippets/visualbasic/api/system.io/path/combine/misc.vb.vbproj
@@ -0,0 +1,9 @@
+
+
+
+ Exe
+ misc.vb
+ netcoreapp2.2
+
+
+
diff --git a/samples/snippets/visualbasic/api/system.io/path/combine2/Program.vb b/samples/snippets/visualbasic/api/system.io/path/combine2/Program.vb
new file mode 100644
index 00000000000..b7d12577aab
--- /dev/null
+++ b/samples/snippets/visualbasic/api/system.io/path/combine2/Program.vb
@@ -0,0 +1,38 @@
+Imports System.IO
+
+Module Example
+ Public Sub Main()
+ Dim path1 = "C:/Program Files/"
+ Dim path2 = "Utilities/SystemUtilities"
+ ShowPathInformation(path1, path2)
+
+ path1 = "C:/"
+ path2 = "/Program Files"
+ ShowPathInformation(path1, path2)
+
+ path1 = "C:/Users/Public/Documents/"
+ path2 = "C:/Users/User1/Documents/Financial/"
+ ShowPathInformation(path1, path2)
+ End Sub
+
+ Private Sub ShowPathInformation(path1 As String, path2 As String)
+ Dim result = Path.Join(path1.AsSpan(), path2.AsSpan())
+ Console.WriteLine($"Concatenating '{path1}' and '{path2}'")
+ Console.WriteLine($" Path.Join: '{result}'")
+ Console.WriteLine($" Path.Combine: '{Path.Combine(path1, path2)}'")
+ Console.WriteLine()
+ End Sub
+End Module
+' The example displays the following output if run on a Windows system:
+' Concatenating 'C:/Program Files/' and 'Utilities/SystemUtilities'
+' Path.Join: 'C:/Program Files/Utilities/SystemUtilities'
+' Path.Combine: 'C:/Program Files/Utilities/SystemUtilities'
+'
+' Concatenating 'C:/' and '/Program Files'
+' Path.Join: 'C:'Program Files'
+' Path.Combine: '/Program Files'
+'
+' Concatenating 'C:/Users/Public/Documents/' and 'C:/Users/User1/Documents/Financial/'
+' Path.Join: 'C:/Users/Public/Documents/C:/Users/User1/Documents/Financial/'
+' Path.Combine: 'C:/Users/User1/Documents/Financial/'
+
diff --git a/samples/snippets/visualbasic/api/system.io/path/combine2/combine2.vbproj b/samples/snippets/visualbasic/api/system.io/path/combine2/combine2.vbproj
new file mode 100644
index 00000000000..b488d997517
--- /dev/null
+++ b/samples/snippets/visualbasic/api/system.io/path/combine2/combine2.vbproj
@@ -0,0 +1,9 @@
+
+
+
+ Exe
+ combine2
+ netcoreapp2.2
+
+
+
diff --git a/samples/snippets/visualbasic/api/system.io/path/combine3/Program.vb b/samples/snippets/visualbasic/api/system.io/path/combine3/Program.vb
new file mode 100644
index 00000000000..a690a67f308
--- /dev/null
+++ b/samples/snippets/visualbasic/api/system.io/path/combine3/Program.vb
@@ -0,0 +1,40 @@
+Imports System.IO
+
+Module Program
+ Public Sub Main()
+ Dim path1 As String = "C:/"
+ Dim path2 As String = "users/user1/documents"
+ Dim path3 As String = "letters"
+ ShowPathInformation(path1, path2, path3)
+
+ path1 = "D:/"
+ path2 = "/users/user1/documents"
+ path3 = "letters"
+ ShowPathInformation(path1, path2, path3)
+
+ path1 = "D:/"
+ path2 = "users/user1/documents"
+ path3 = "C:/users/user1/documents/data"
+ ShowPathInformation(path1, path2, path3)
+ End Sub
+
+ Private Sub ShowPathInformation(path1 As String, path2 As String, path3 As String)
+ Dim result = Path.Join(path1.AsSpan(), path2.AsSpan(), path3.AsSpan())
+ Console.WriteLine($"Concatenating '{path1}, '{path2}', and `{path3}'")
+ Console.WriteLine($" Path.Join: '{result}'")
+ Console.WriteLine($" Path.Combine: '{Path.Combine(path1, path2, path3)}'")
+ End Sub
+End Module
+' The example displays the following output if run on a Windows system:
+' Concatenating 'C:/, 'users/user1/documents', and `letters'
+' Path.Join: 'C:/users/user1/documents\letters'
+' Path.Combine: 'C:/users/user1/documents\letters'
+'
+' Concatenating 'D:/, '/users/user1/documents', and `letters'
+' Path.Join: 'D:'users/user1/documents\letters'
+' Path.Combine: '/users/user1/documents\letters'
+'
+' Concatenating 'D:/, 'users/user1/documents', and `C:/users/user1/documents/data'
+' Path.Join: 'D:/users/user1/documents\C:/users/user1/documents/data'
+' Path.Combine: 'C:/users/user1/documents/data'
+
\ No newline at end of file
diff --git a/samples/snippets/visualbasic/api/system.io/path/combine3/combine3.vbproj b/samples/snippets/visualbasic/api/system.io/path/combine3/combine3.vbproj
new file mode 100644
index 00000000000..1ff35a27ba6
--- /dev/null
+++ b/samples/snippets/visualbasic/api/system.io/path/combine3/combine3.vbproj
@@ -0,0 +1,9 @@
+
+
+
+ Exe
+ combine3
+ netcoreapp2.2
+
+
+
diff --git a/samples/snippets/visualbasic/api/system.io/path/directoryseparatorchar/Program.vb b/samples/snippets/visualbasic/api/system.io/path/directoryseparatorchar/Program.vb
new file mode 100644
index 00000000000..32f9dc012b3
--- /dev/null
+++ b/samples/snippets/visualbasic/api/system.io/path/directoryseparatorchar/Program.vb
@@ -0,0 +1,36 @@
+Imports System.IO
+
+Module Program
+ Sub Main()
+ Console.WriteLine($"Path.DirectorySeparatorChar: '{Path.DirectorySeparatorChar}'")
+ Console.WriteLine($"Path.AltDirectorySeparatorChar: '{Path.AltDirectorySeparatorChar}'")
+ Console.WriteLine($"Path.PathSeparator: '{Path.PathSeparator}'")
+ Console.WriteLine($"Path.VolumeSeparatorChar: '{Path.VolumeSeparatorChar}'")
+ Dim invalidChars = Path.GetInvalidPathChars()
+ Console.WriteLine($"Path.GetInvalidPathChars:")
+ For ctr As Integer = 0 To invalidChars.Length - 1
+ Console.Write($" U+{Convert.ToUInt16(invalidChars(ctr)):X4} ")
+ if (ctr + 1) Mod 10 = 0 Then Console.WriteLine()
+ Next
+ Console.WriteLine()
+ Console.WriteLine("Hello World!")
+ End Sub
+End Module
+' The example displays the following output when run on a Windows system:
+' Path.DirectorySeparatorChar: '\'
+' Path.AltDirectorySeparatorChar: '/'
+' Path.PathSeparator: ';'
+' Path.VolumeSeparatorChar: ':'
+' Path.GetInvalidPathChars:
+' U+007C) U+0000) U+0001) U+0002) U+0003) U+0004) U+0005) U+0006) U+0007) U+0008)
+' U+0009) U+000A) U+000B) U+000C) U+000D) U+000E) U+000F) U+0010) U+0011) U+0012)
+' U+0013) U+0014) U+0015) U+0016) U+0017) U+0018) U+0019) U+001A) U+001B) U+001C)
+' U+001D) U+001E) U+001F)
+'
+' The example displays the following output when run on a Linux system:
+' Path.DirectorySeparatorChar: '/'
+' Path.AltDirectorySeparatorChar: '/'
+' Path.PathSeparator: ':'
+' Path.VolumeSeparatorChar: '/'
+' Path.GetInvalidPathChars:
+' U+0000
diff --git a/samples/snippets/visualbasic/api/system.io/path/directoryseparatorchar/directoryseparatorchar.vbproj b/samples/snippets/visualbasic/api/system.io/path/directoryseparatorchar/directoryseparatorchar.vbproj
new file mode 100644
index 00000000000..8c086f6d813
--- /dev/null
+++ b/samples/snippets/visualbasic/api/system.io/path/directoryseparatorchar/directoryseparatorchar.vbproj
@@ -0,0 +1,9 @@
+
+
+
+ Exe
+ directoryseparatorchar.vb
+ netcoreapp2.2
+
+
+
diff --git a/samples/snippets/visualbasic/api/system.io/path/getfullpath/Program.vb b/samples/snippets/visualbasic/api/system.io/path/getfullpath/Program.vb
new file mode 100644
index 00000000000..e714aab3af8
--- /dev/null
+++ b/samples/snippets/visualbasic/api/system.io/path/getfullpath/Program.vb
@@ -0,0 +1,20 @@
+Imports System.IO
+
+Module Program
+ Public Sub Main()
+ Dim basePath As String = Environment.CurrentDirectory
+ Dim relativePath As String = "./data/output.xml"
+
+ ' Unexpectedly change the current directory.
+ Environment.CurrentDirectory = "C:/Users/Public/Documents/"
+
+ Dim fullPath As String = Path.GetFullPath(relativePath, basePath)
+ Console.WriteLine($"Current directory:\n {Environment.CurrentDirectory}")
+ Console.WriteLine($"Fully qualified path:\n {fullPath}")
+ End Sub
+End Module
+' The example displays the following output:
+' Current directory:
+' C:\Users\Public\Documents
+' Fully qualified path:
+' C:\Utilities\data\output.xml
\ No newline at end of file
diff --git a/samples/snippets/visualbasic/api/system.io/path/getfullpath/getfullpath.vbproj b/samples/snippets/visualbasic/api/system.io/path/getfullpath/getfullpath.vbproj
new file mode 100644
index 00000000000..26668358aca
--- /dev/null
+++ b/samples/snippets/visualbasic/api/system.io/path/getfullpath/getfullpath.vbproj
@@ -0,0 +1,9 @@
+
+
+
+ Exe
+ getfullpath
+ netcoreapp2.2
+
+
+
diff --git a/samples/snippets/visualbasic/api/system.security.cryptography/hashalgorithm/example1.vb b/samples/snippets/visualbasic/api/system.security.cryptography/hashalgorithm/example1.vb
new file mode 100644
index 00000000000..c4f13f1dc3b
--- /dev/null
+++ b/samples/snippets/visualbasic/api/system.security.cryptography/hashalgorithm/example1.vb
@@ -0,0 +1,56 @@
+Imports System.Security.Cryptography
+Imports System.Text
+
+Public Module Program
+ Public Sub Main()
+ Dim source As String = "Hello World!"
+ Using sha256Hash As SHA256 = SHA256.Create()
+
+ Dim hash As String = GetHash(sha256Hash, source)
+
+ Console.WriteLine($"The SHA256 hash of {source} is: {hash}.")
+
+ Console.WriteLine("Verifying the hash...")
+
+ If VerifyHash(sha256Hash, source, hash) Then
+ Console.WriteLine("The hashes are the same.")
+ Else
+ Console.WriteLine("The hashes are not same.")
+ End If
+ End Using
+ End Sub
+
+ Private Function GetHash(ByVal hashAlgorithm As HashAlgorithm, ByVal input As String) As String
+
+ ' Convert the input string to a byte array and compute the hash.
+ Dim data As Byte() = hashAlgorithm.ComputeHash(Encoding.UTF8.GetBytes(input))
+
+ ' Create a new Stringbuilder to collect the bytes
+ ' and create a string.
+ Dim sBuilder As New StringBuilder()
+
+ ' Loop through each byte of the hashed data
+ ' and format each one as a hexadecimal string.
+ For i As Integer = 0 To data.Length - 1
+ sBuilder.Append(data(i).ToString("x2"))
+ Next
+
+ ' Return the hexadecimal string.
+ Return sBuilder.ToString()
+ End Function
+
+ ' Verify a hash against a string.
+ Private Function VerifyHash(hashAlgorithm As HashAlgorithm, input As String, hash As String) As Boolean
+ ' Hash the input.
+ Dim hashOfInput As String = GetHash(hashAlgorithm, input)
+
+ ' Create a StringComparer an compare the hashes.
+ Dim comparer As StringComparer = StringComparer.OrdinalIgnoreCase
+
+ Return comparer.Compare(hashOfInput, hash) = 0
+ End Function
+End Module
+' The example displays the following output:
+' The SHA256 hash of Hello World! is: 7f83b1657ff1fc53b92dc18148a1d65dfc2d4b1fa3d677284addd200126d9069.
+' Verifying the hash...
+' The hashes are the same.
diff --git a/samples/snippets/visualbasic/api/system.xml.linq/xnode/readfrom/Program.vb b/samples/snippets/visualbasic/api/system.xml.linq/xnode/readfrom/Program.vb
new file mode 100644
index 00000000000..4c82fbdd62e
--- /dev/null
+++ b/samples/snippets/visualbasic/api/system.xml.linq/xnode/readfrom/Program.vb
@@ -0,0 +1,38 @@
+Imports System.Collections.Generic
+Imports System.Linq
+Imports System.Xml
+Imports System.Xml.Linq
+
+Module Program
+ Iterator Function StreamRootChildDoc(ByVal uri As String) As IEnumerable(Of XElement)
+
+ Using reader As XmlReader = XmlReader.Create(uri)
+ reader.MoveToContent()
+
+ ' Parse the file and return each of the nodes.
+ While Not reader.EOF
+
+ If reader.NodeType = XmlNodeType.Element AndAlso reader.Name = "Child" Then
+ Dim el As XElement = TryCast(XElement.ReadFrom(reader), XElement)
+ If el IsNot Nothing Then Yield el
+ Else
+ reader.Read()
+ End If
+ End While
+ End Using
+ End Function
+
+ Sub Main(args As String())
+
+ Dim grandChildData As IEnumerable(Of String) =
+ From el In StreamRootChildDoc("Source.xml")
+ Where CInt(el.Attribute("Key")) > 1
+ Select CStr(el.Element("GrandChild"))
+
+ For Each str As String In grandChildData
+ Console.WriteLine(str)
+ Next
+
+ End Sub
+
+End Module
\ No newline at end of file
diff --git a/samples/snippets/visualbasic/api/system.xml.linq/xnode/readfrom/Source.xml b/samples/snippets/visualbasic/api/system.xml.linq/xnode/readfrom/Source.xml
new file mode 100644
index 00000000000..b823058ec1c
--- /dev/null
+++ b/samples/snippets/visualbasic/api/system.xml.linq/xnode/readfrom/Source.xml
@@ -0,0 +1,12 @@
+
+
+
+ aaa
+
+
+ bbb
+
+
+ ccc
+
+
\ No newline at end of file
diff --git a/samples/snippets/visualbasic/api/system.xml.linq/xnode/readfrom/readfrom.vbproj b/samples/snippets/visualbasic/api/system.xml.linq/xnode/readfrom/readfrom.vbproj
new file mode 100644
index 00000000000..0d182e78911
--- /dev/null
+++ b/samples/snippets/visualbasic/api/system.xml.linq/xnode/readfrom/readfrom.vbproj
@@ -0,0 +1,14 @@
+
+
+
+ Exe
+ netcoreapp2.2;net472
+
+
+
+
+ PreserveNewest
+
+
+
+
\ No newline at end of file
diff --git a/samples/snippets/visualbasic/api/system.xml/xmlexception/Program.vb b/samples/snippets/visualbasic/api/system.xml/xmlexception/Program.vb
new file mode 100644
index 00000000000..e3ab6e17d0e
--- /dev/null
+++ b/samples/snippets/visualbasic/api/system.xml/xmlexception/Program.vb
@@ -0,0 +1,11 @@
+Try
+ Dim contacts As XElement = XElement.Parse(
+ "
+
+ Jim Wilson
+
+ ")
+ Console.WriteLine(contacts)
+Catch e As System.Xml.XmlException
+ Console.WriteLine(e.Message)
+End Try
diff --git a/samples/snippets/visualbasic/api/system/datetimeoffset/parseexact/parseexact-iso8601-2.vb b/samples/snippets/visualbasic/api/system/datetimeoffset/parseexact/parseexact-iso8601-2.vb
new file mode 100644
index 00000000000..e2975245554
--- /dev/null
+++ b/samples/snippets/visualbasic/api/system/datetimeoffset/parseexact/parseexact-iso8601-2.vb
@@ -0,0 +1,88 @@
+Imports System.Globalization
+
+Public Module Example
+ Public Sub Main()
+ Dim dateStrings() = { "2018-08-18T12:45:16.0000000Z",
+ "2018/08/18T12:45:16.0000000Z",
+ "2018-18-08T12:45:16.0000000Z",
+ "2018-08-18T12:45:16.0000000",
+ " 2018-08-18T12:45:16.0000000Z ",
+ "2018-08-18T12:45:16.0000000+02:00",
+ "2018-08-18T12:45:16.0000000-07:00" }
+
+ ParseWithISO8601(dateStrings, DateTimeStyles.None)
+ Console.WriteLine($"{vbCrLf}-----{vbCrLf}")
+ ParseWithISO8601(dateStrings, DateTimeStyles.AllowWhiteSpaces)
+ Console.WriteLine($"{vbCrLf}-----{vbCrLf}")
+ ParseWithISO8601(dateStrings, DateTimeStyles.AdjustToUniversal)
+ Console.WriteLine($"{vbCrLf}-----{vbCrLf}")
+ ParseWithISO8601(dateStrings, DateTimeStyles.AssumeLocal)
+ Console.WriteLine($"{vbCrLf}-----{vbCrLf}")
+ ParseWithISO8601(dateStrings, DateTimeStyles.AssumeUniversal)
+ End Sub
+
+ Private Sub ParseWithISO8601(dateStrings() As String, styles As DateTimeStyles)
+ Console.WriteLine($"Parsing with {styles}:")
+ For Each dateStr In dateStrings
+ Try
+ Dim dat = DateTimeOffset.ParseExact(dateString, "O", Nothing, styles)
+ Console.WriteLine($" {dateString,-35} --> {dat:yyyy-MM-dd HH:mm:ss.FF zzz}")
+ catch e As FormatException
+ Console.WriteLine($" FormatException: Unable to convert '{dateString}'")
+ End Try
+ Next
+ End Sub
+End Module
+' The example displays the following output:
+' Parsing with None:
+' FormatException: Unable to convert '07-30-2018'
+' FormatException: Unable to convert '07-30-2018'
+' FormatException: Unable to convert '07-30-2018'
+' FormatException: Unable to convert '07-30-2018'
+' FormatException: Unable to convert '07-30-2018'
+' FormatException: Unable to convert '07-30-2018'
+' FormatException: Unable to convert '07-30-2018'
+'
+' -----
+'
+' Parsing with AllowWhiteSpaces:
+' FormatException: Unable to convert '07-30-2018'
+' FormatException: Unable to convert '07-30-2018'
+' FormatException: Unable to convert '07-30-2018'
+' FormatException: Unable to convert '07-30-2018'
+' FormatException: Unable to convert '07-30-2018'
+' FormatException: Unable to convert '07-30-2018'
+' FormatException: Unable to convert '07-30-2018'
+'
+' -----
+'
+' Parsing with AdjustToUniversal:
+' FormatException: Unable to convert '07-30-2018'
+' FormatException: Unable to convert '07-30-2018'
+' FormatException: Unable to convert '07-30-2018'
+' FormatException: Unable to convert '07-30-2018'
+' FormatException: Unable to convert '07-30-2018'
+' FormatException: Unable to convert '07-30-2018'
+' FormatException: Unable to convert '07-30-2018'
+'
+' -----
+'
+' Parsing with AssumeLocal:
+' FormatException: Unable to convert '07-30-2018'
+' FormatException: Unable to convert '07-30-2018'
+' FormatException: Unable to convert '07-30-2018'
+' FormatException: Unable to convert '07-30-2018'
+' FormatException: Unable to convert '07-30-2018'
+' FormatException: Unable to convert '07-30-2018'
+' FormatException: Unable to convert '07-30-2018'
+'
+' -----
+'
+' Parsing with AssumeUniversal:
+' FormatException: Unable to convert '07-30-2018'
+' FormatException: Unable to convert '07-30-2018'
+' FormatException: Unable to convert '07-30-2018'
+' FormatException: Unable to convert '07-30-2018'
+' FormatException: Unable to convert '07-30-2018'
+' FormatException: Unable to convert '07-30-2018'
+' FormatException: Unable to convert '07-30-2018'
diff --git a/samples/snippets/visualbasic/api/system/datetimeoffset/parseexact/parseexact-iso8601.vb b/samples/snippets/visualbasic/api/system/datetimeoffset/parseexact/parseexact-iso8601.vb
new file mode 100644
index 00000000000..4aff838ae00
--- /dev/null
+++ b/samples/snippets/visualbasic/api/system/datetimeoffset/parseexact/parseexact-iso8601.vb
@@ -0,0 +1,26 @@
+Public Module Example
+ Public Sub Main()
+ Dim dateStrings() As String = { "2018-08-18T12:45:16.0000000Z",
+ "2018/08/18T12:45:16.0000000Z",
+ "2018-18-08T12:45:16.0000000Z",
+ " 2018-08-18T12:45:16.0000000Z ",
+ "2018-08-18T12:45:16.0000000+02:00",
+ "2018-08-18T12:45:16.0000000-07:00" }
+
+ For Each dateStr In dateStrings
+ Try
+ Dim dat = DateTimeOffset.ParseExact(dateStr, "O", Nothing)
+ Console.WriteLine($"{dateStr,-35} --> {dat:yyyy-MM-dd HH:mm:ss.FF zzz}")
+ Catch e As FormatException
+ Console.WriteLine($"FormatException: Unable to convert '{dateStr}'")
+ End Try
+ Next
+ End Sub
+End Module
+' The example displays the following output:
+' 2018-08-18T12:45:16.0000000Z --> 2018-08-18 12:45:16 +00:00
+' FormatException: Unable to convert '2018/08/18T12:45:16.0000000Z'
+' FormatException: Unable to convert '2018-18-08T12:45:16.0000000Z'
+' FormatException: Unable to convert ' 2018-08-18T12:45:16.0000000Z '
+' 2018-08-18T12:45:16.0000000+02:00 --> 2018-08-18 12:45:16 +02:00
+' 2018-08-18T12:45:16.0000000-07:00 --> 2018-08-18 12:45:16 -07:00
diff --git a/samples/snippets/visualbasic/api/system/datetimeoffset/tryparseexact/tryparseexacto8601-2.vb b/samples/snippets/visualbasic/api/system/datetimeoffset/tryparseexact/tryparseexacto8601-2.vb
new file mode 100644
index 00000000000..7bc6249cc99
--- /dev/null
+++ b/samples/snippets/visualbasic/api/system/datetimeoffset/tryparseexact/tryparseexacto8601-2.vb
@@ -0,0 +1,88 @@
+Imports System.Globalization
+
+Public Module Example
+ Public Sub Main()
+ Dim dateStrings() = { "2018-08-18T12:45:16.0000000Z",
+ "2018/08/18T12:45:16.0000000Z",
+ "2018-18-08T12:45:16.0000000Z",
+ "2018-08-18T12:45:16.0000000",
+ " 2018-08-18T12:45:16.0000000Z ",
+ "2018-08-18T12:45:16.0000000+02:00",
+ "2018-08-18T12:45:16.0000000-07:00" }
+
+ ParseWithISO8601(dateStrings, DateTimeStyles.None)
+ Console.WriteLine($"{vbCrLf}-----{vbCrLf}")
+ ParseWithISO8601(dateStrings, DateTimeStyles.AllowWhiteSpaces)
+ Console.WriteLine($"{vbCrLf}-----{vbCrLf}")
+ ParseWithISO8601(dateStrings, DateTimeStyles.AdjustToUniversal)
+ Console.WriteLine($"{vbCrLf}-----{vbCrLf}")
+ ParseWithISO8601(dateStrings, DateTimeStyles.AssumeLocal)
+ Console.WriteLine($"{vbCrLf}-----{vbCrLf}")
+ ParseWithISO8601(dateStrings, DateTimeStyles.AssumeUniversal)
+ End Sub
+
+ Private Sub ParseWithISO8601(dateStrings() As String, styles As DateTimeStyles)
+ Console.WriteLine($"Parsing with {styles}:")
+ Dim dat As DateTimeOffset
+ For Each dateStr In dateStrings
+ If DateTimeOffset.TryParseExact(dateStr, "O", Nothing, styles, dat) Then
+ Console.WriteLine($" {dateStr,-35} --> {dat:yyyy-MM-dd HH:mm:ss.FF zzz}")
+ Else
+ Console.WriteLine($" Unable to convert '{dateStr}'")
+ End If
+ Next
+ End Sub
+End Module
+' The example displays the following output:
+' Parsing with None:
+' 2018-08-18T12:45:16.0000000Z --> 2018-08-18 12:45:16 +00:00
+' Unable to convert '2018/08/18T12:45:16.0000000Z'
+' Unable to convert '2018-18-08T12:45:16.0000000Z'
+' 2018-08-18T12:45:16.0000000 --> 2018-08-18 12:45:16 -07:00
+' Unable to convert ' 2018-08-18T12:45:16.0000000Z '
+' 2018-08-18T12:45:16.0000000+02:00 --> 2018-08-18 12:45:16 +02:00
+' 2018-08-18T12:45:16.0000000-07:00 --> 2018-08-18 12:45:16 -07:00
+'
+' -----
+'
+' Parsing with AllowWhiteSpaces:
+' 2018-08-18T12:45:16.0000000Z --> 2018-08-18 12:45:16 +00:00
+' Unable to convert '2018/08/18T12:45:16.0000000Z'
+' Unable to convert '2018-18-08T12:45:16.0000000Z'
+' 2018-08-18T12:45:16.0000000 --> 2018-08-18 12:45:16 -07:00
+' 2018-08-18T12:45:16.0000000Z --> 2018-08-18 12:45:16 +00:00
+' 2018-08-18T12:45:16.0000000+02:00 --> 2018-08-18 12:45:16 +02:00
+' 2018-08-18T12:45:16.0000000-07:00 --> 2018-08-18 12:45:16 -07:00
+'
+' -----
+'
+' Parsing with AdjustToUniversal:
+' 2018-08-18T12:45:16.0000000Z --> 2018-08-18 12:45:16 +00:00
+' Unable to convert '2018/08/18T12:45:16.0000000Z'
+' Unable to convert '2018-18-08T12:45:16.0000000Z'
+' 2018-08-18T12:45:16.0000000 --> 2018-08-18 19:45:16 +00:00
+' Unable to convert ' 2018-08-18T12:45:16.0000000Z '
+' 2018-08-18T12:45:16.0000000+02:00 --> 2018-08-18 10:45:16 +00:00
+' 2018-08-18T12:45:16.0000000-07:00 --> 2018-08-18 19:45:16 +00:00
+'
+' -----
+'
+' Parsing with AssumeLocal:
+' 2018-08-18T12:45:16.0000000Z --> 2018-08-18 12:45:16 +00:00
+' Unable to convert '2018/08/18T12:45:16.0000000Z'
+' Unable to convert '2018-18-08T12:45:16.0000000Z'
+' 2018-08-18T12:45:16.0000000 --> 2018-08-18 12:45:16 -07:00
+' Unable to convert ' 2018-08-18T12:45:16.0000000Z '
+' 2018-08-18T12:45:16.0000000+02:00 --> 2018-08-18 12:45:16 +02:00
+' 2018-08-18T12:45:16.0000000-07:00 --> 2018-08-18 12:45:16 -07:00
+'
+' -----
+'
+' Parsing with AssumeUniversal:
+' 2018-08-18T12:45:16.0000000Z --> 2018-08-18 12:45:16 +00:00
+' Unable to convert '2018/08/18T12:45:16.0000000Z'
+' Unable to convert '2018-18-08T12:45:16.0000000Z'
+' 2018-08-18T12:45:16.0000000 --> 2018-08-18 12:45:16 +00:00
+' Unable to convert ' 2018-08-18T12:45:16.0000000Z '
+' 2018-08-18T12:45:16.0000000+02:00 --> 2018-08-18 12:45:16 +02:00
+' 2018-08-18T12:45:16.0000000-07:00 --> 2018-08-18 12:45:16 -07:00
\ No newline at end of file
diff --git a/samples/snippets/visualbasic/api/system/string/copy/Program.vb b/samples/snippets/visualbasic/api/system/string/copy/Program.vb
new file mode 100644
index 00000000000..6f7e2385118
--- /dev/null
+++ b/samples/snippets/visualbasic/api/system/string/copy/Program.vb
@@ -0,0 +1,38 @@
+Imports System.Runtime.CompilerServices
+Imports System.Text
+
+Module Program
+ Sub Main()
+ PerformStringOperation()
+ Console.WriteLine("---")
+ UseMutableBuffer()
+ Console.WriteLine("---")
+ End Sub
+
+ Private Sub PerformStringOperation()
+ '
+ Dim original = "This is a sentence. This is a second sentence."
+ Dim sentence1 = original.Substring(0, original.IndexOf(".") + 1)
+ Console.WriteLine(original)
+ Console.WriteLine(sentence1)
+ ' The example displays the following output:
+ ' This is a sentence. This is a second sentence.
+ ' This is a sentence.
+ '
+ End Sub
+
+ '
+ Private Sub UseMutableBuffer()
+ Dim original = "This is a sentence. This is a second sentence."
+ Dim sb = new StringBuilder(original)
+ Dim index = original.IndexOf(".")
+ sb(index) = ";"
+ sb(index + 2) = Char.ToLower(sb(index + 2))
+ Console.WriteLine($"Original string: {original}")
+ Console.WriteLine($"Modified string: {sb.ToString()}")
+ End Sub
+ ' The example displays the following output:
+ ' Original string: This is a sentence. This is a second sentence.
+ ' Modified string: This is a sentence; this is a second sentence.
+ '
+End Module
diff --git a/samples/snippets/visualbasic/api/system/string/copy/copy.vbproj b/samples/snippets/visualbasic/api/system/string/copy/copy.vbproj
new file mode 100644
index 00000000000..0060cd31eed
--- /dev/null
+++ b/samples/snippets/visualbasic/api/system/string/copy/copy.vbproj
@@ -0,0 +1,9 @@
+
+
+
+ Exe
+ copy.vb
+ netcoreapp3.0
+
+
+