From f3170c6bb994c061dfbd00068543628940475d14 Mon Sep 17 00:00:00 2001 From: Genevieve Warren <24882762+gewarren@users.noreply.github.com> Date: Wed, 3 Jun 2026 21:06:59 -0700 Subject: [PATCH 1/4] Reinstate supplemental remarks --- .../Regex/Match/Project.csproj | 6 +- .../Regex/Match/startat.cs | 20 ++ .../Encoding/Overview/Project.csproj | 8 + .../Encoding/Overview/getencoding1.cs | 90 +++++++ .../StringBuilder/Overview/Project.csproj | 9 + .../StringBuilder/Overview/call1.cs | 19 ++ .../StringBuilder/Overview/call2.cs | 17 ++ .../StringBuilder/Overview/chars1.cs | 46 ++++ .../StringBuilder/Overview/default1.cs | 45 ++++ .../StringBuilder/Overview/delete1.cs | 44 ++++ .../StringBuilder/Overview/expand1.cs | 49 ++++ .../StringBuilder/Overview/immutability2.cs | 21 ++ .../StringBuilder/Overview/instantiate1.cs | 48 ++++ .../StringBuilder/Overview/pattern1.cs | 66 +++++ .../StringBuilder/Overview/pattern2.cs | 45 ++++ .../StringBuilder/Overview/pattern3.cs | 48 ++++ .../StringBuilder/Overview/pattern4.cs | 41 ++++ .../StringBuilder/Overview/replace1.cs | 16 ++ .../Encoding/Overview/Project.vbproj | 8 + .../Encoding/Overview/getencoding1.vb | 90 +++++++ .../StringBuilder/Overview/Project.vbproj | 8 + .../StringBuilder/Overview/call1.vb | 19 ++ .../StringBuilder/Overview/call2.vb | 17 ++ .../StringBuilder/Overview/chars1.vb | 46 ++++ .../StringBuilder/Overview/default1.vb | 43 ++++ .../StringBuilder/Overview/delete1.vb | 44 ++++ .../StringBuilder/Overview/expand1.vb | 49 ++++ .../StringBuilder/Overview/instantiate1.vb | 49 ++++ .../StringBuilder/Overview/pattern1.vb | 60 +++++ .../StringBuilder/Overview/pattern2.vb | 43 ++++ .../StringBuilder/Overview/pattern3.vb | 42 ++++ .../StringBuilder/Overview/pattern4.vb | 40 +++ .../StringBuilder/Overview/replace1.vb | 16 ++ .../Task/Overview/Project.vbproj | 8 + .../Task/Overview/Wait1.vb | 24 ++ .../Task/Overview/Wait2.vb | 28 +++ .../Task/Overview/WaitAll1.vb | 42 ++++ .../Task/Overview/WaitAll2.vb | 98 ++++++++ .../Task/Overview/WaitAny1.vb | 35 +++ .../Task/Overview/run1.vb | 22 ++ .../Task/Overview/startnew.vb | 54 ++++ .../Task/Overview/startnew1.vb | 22 ++ .../TaskScheduler/Overview/Application.xaml | 9 + .../Overview/Application.xaml.vb | 6 + .../TaskScheduler/Overview/AssemblyInfo.vb | 11 + .../TaskScheduler/Overview/MainWindow.xaml | 14 ++ .../TaskScheduler/Overview/MainWindow.xaml.vb | 143 +++++++++++ .../TaskScheduler/Overview/WpfApp.vbproj | 22 ++ .../Monitor/Overview/Pattern2.vb | 32 +++ .../Monitor/Overview/Project.vbproj | 8 + .../Monitor/Overview/badbox1.vb | 47 ++++ .../Monitor/Overview/badlock1.vb | 60 +++++ .../Monitor/Overview/example1.vb | 66 +++++ .../Monitor/Overview/source.vb | 110 +++++++++ .../Overview/Project.vbproj | 8 + .../Overview/classexample1.vb | 211 ++++++++++++++++ .../Thread/Overview/BackgroundEx1.vb | 39 +++ .../Thread/Overview/Instance1.vb | 63 +++++ .../Thread/Overview/Project.vbproj | 8 + .../Thread/Overview/ThreadStart1.vb | 46 ++++ .../Thread/Overview/ThreadStart2.vb | 51 ++++ .../Thread/Overview/source.vb | 45 ++++ xml/System.Text.RegularExpressions/Regex.xml | 46 +++- xml/System.Text/Encoding.xml | 217 +++++++++++++++- xml/System.Text/Rune.xml | 194 ++++++++++++++- xml/System.Text/StringBuilder.xml | 201 ++++++++++++++- xml/System.Threading.Tasks/Task.xml | 99 +++++++- xml/System.Threading.Tasks/TaskScheduler.xml | 59 ++++- xml/System.Threading/Monitor.xml | 232 +++++++++++++++++- xml/System.Threading/ReaderWriterLockSlim.xml | 132 +++++++++- xml/System.Threading/Thread.xml | 160 +++++++++++- 71 files changed, 3866 insertions(+), 18 deletions(-) create mode 100644 snippets/csharp/System.Text.RegularExpressions/Regex/Match/startat.cs create mode 100644 snippets/csharp/System.Text/Encoding/Overview/Project.csproj create mode 100644 snippets/csharp/System.Text/Encoding/Overview/getencoding1.cs create mode 100644 snippets/csharp/System.Text/StringBuilder/Overview/Project.csproj create mode 100644 snippets/csharp/System.Text/StringBuilder/Overview/call1.cs create mode 100644 snippets/csharp/System.Text/StringBuilder/Overview/call2.cs create mode 100644 snippets/csharp/System.Text/StringBuilder/Overview/chars1.cs create mode 100644 snippets/csharp/System.Text/StringBuilder/Overview/default1.cs create mode 100644 snippets/csharp/System.Text/StringBuilder/Overview/delete1.cs create mode 100644 snippets/csharp/System.Text/StringBuilder/Overview/expand1.cs create mode 100644 snippets/csharp/System.Text/StringBuilder/Overview/immutability2.cs create mode 100644 snippets/csharp/System.Text/StringBuilder/Overview/instantiate1.cs create mode 100644 snippets/csharp/System.Text/StringBuilder/Overview/pattern1.cs create mode 100644 snippets/csharp/System.Text/StringBuilder/Overview/pattern2.cs create mode 100644 snippets/csharp/System.Text/StringBuilder/Overview/pattern3.cs create mode 100644 snippets/csharp/System.Text/StringBuilder/Overview/pattern4.cs create mode 100644 snippets/csharp/System.Text/StringBuilder/Overview/replace1.cs create mode 100644 snippets/visualbasic/System.Text/Encoding/Overview/Project.vbproj create mode 100644 snippets/visualbasic/System.Text/Encoding/Overview/getencoding1.vb create mode 100644 snippets/visualbasic/System.Text/StringBuilder/Overview/Project.vbproj create mode 100644 snippets/visualbasic/System.Text/StringBuilder/Overview/call1.vb create mode 100644 snippets/visualbasic/System.Text/StringBuilder/Overview/call2.vb create mode 100644 snippets/visualbasic/System.Text/StringBuilder/Overview/chars1.vb create mode 100644 snippets/visualbasic/System.Text/StringBuilder/Overview/default1.vb create mode 100644 snippets/visualbasic/System.Text/StringBuilder/Overview/delete1.vb create mode 100644 snippets/visualbasic/System.Text/StringBuilder/Overview/expand1.vb create mode 100644 snippets/visualbasic/System.Text/StringBuilder/Overview/instantiate1.vb create mode 100644 snippets/visualbasic/System.Text/StringBuilder/Overview/pattern1.vb create mode 100644 snippets/visualbasic/System.Text/StringBuilder/Overview/pattern2.vb create mode 100644 snippets/visualbasic/System.Text/StringBuilder/Overview/pattern3.vb create mode 100644 snippets/visualbasic/System.Text/StringBuilder/Overview/pattern4.vb create mode 100644 snippets/visualbasic/System.Text/StringBuilder/Overview/replace1.vb create mode 100644 snippets/visualbasic/System.Threading.Tasks/Task/Overview/Project.vbproj create mode 100644 snippets/visualbasic/System.Threading.Tasks/Task/Overview/Wait1.vb create mode 100644 snippets/visualbasic/System.Threading.Tasks/Task/Overview/Wait2.vb create mode 100644 snippets/visualbasic/System.Threading.Tasks/Task/Overview/WaitAll1.vb create mode 100644 snippets/visualbasic/System.Threading.Tasks/Task/Overview/WaitAll2.vb create mode 100644 snippets/visualbasic/System.Threading.Tasks/Task/Overview/WaitAny1.vb create mode 100644 snippets/visualbasic/System.Threading.Tasks/Task/Overview/run1.vb create mode 100644 snippets/visualbasic/System.Threading.Tasks/Task/Overview/startnew.vb create mode 100644 snippets/visualbasic/System.Threading.Tasks/Task/Overview/startnew1.vb create mode 100644 snippets/visualbasic/System.Threading.Tasks/TaskScheduler/Overview/Application.xaml create mode 100644 snippets/visualbasic/System.Threading.Tasks/TaskScheduler/Overview/Application.xaml.vb create mode 100644 snippets/visualbasic/System.Threading.Tasks/TaskScheduler/Overview/AssemblyInfo.vb create mode 100644 snippets/visualbasic/System.Threading.Tasks/TaskScheduler/Overview/MainWindow.xaml create mode 100644 snippets/visualbasic/System.Threading.Tasks/TaskScheduler/Overview/MainWindow.xaml.vb create mode 100644 snippets/visualbasic/System.Threading.Tasks/TaskScheduler/Overview/WpfApp.vbproj create mode 100644 snippets/visualbasic/System.Threading/Monitor/Overview/Pattern2.vb create mode 100644 snippets/visualbasic/System.Threading/Monitor/Overview/Project.vbproj create mode 100644 snippets/visualbasic/System.Threading/Monitor/Overview/badbox1.vb create mode 100644 snippets/visualbasic/System.Threading/Monitor/Overview/badlock1.vb create mode 100644 snippets/visualbasic/System.Threading/Monitor/Overview/example1.vb create mode 100644 snippets/visualbasic/System.Threading/Monitor/Overview/source.vb create mode 100644 snippets/visualbasic/System.Threading/ReaderWriterLockSlim/Overview/Project.vbproj create mode 100644 snippets/visualbasic/System.Threading/ReaderWriterLockSlim/Overview/classexample1.vb create mode 100644 snippets/visualbasic/System.Threading/Thread/Overview/BackgroundEx1.vb create mode 100644 snippets/visualbasic/System.Threading/Thread/Overview/Instance1.vb create mode 100644 snippets/visualbasic/System.Threading/Thread/Overview/Project.vbproj create mode 100644 snippets/visualbasic/System.Threading/Thread/Overview/ThreadStart1.vb create mode 100644 snippets/visualbasic/System.Threading/Thread/Overview/ThreadStart2.vb create mode 100644 snippets/visualbasic/System.Threading/Thread/Overview/source.vb diff --git a/snippets/csharp/System.Text.RegularExpressions/Regex/Match/Project.csproj b/snippets/csharp/System.Text.RegularExpressions/Regex/Match/Project.csproj index 0735dba1f6d..874c98f3477 100644 --- a/snippets/csharp/System.Text.RegularExpressions/Regex/Match/Project.csproj +++ b/snippets/csharp/System.Text.RegularExpressions/Regex/Match/Project.csproj @@ -2,7 +2,7 @@ Library - net6.0 + net10.0 - - + + diff --git a/snippets/csharp/System.Text.RegularExpressions/Regex/Match/startat.cs b/snippets/csharp/System.Text.RegularExpressions/Regex/Match/startat.cs new file mode 100644 index 00000000000..f4ed0b262fa --- /dev/null +++ b/snippets/csharp/System.Text.RegularExpressions/Regex/Match/startat.cs @@ -0,0 +1,20 @@ +using System; +using System.Text.RegularExpressions; + +namespace Examples +{ + public class Example3 + { + public static void Main() + { + string input = "Zip code: 98052"; + var regex = new Regex(@"(?<=Zip code: )\d{5}"); + Match match = regex.Match(input, 5); + if (match.Success) + Console.WriteLine($"Match found: {match.Value}"); + } + } +} + +// This code prints the following output: +// Match found: 98052 diff --git a/snippets/csharp/System.Text/Encoding/Overview/Project.csproj b/snippets/csharp/System.Text/Encoding/Overview/Project.csproj new file mode 100644 index 00000000000..874c98f3477 --- /dev/null +++ b/snippets/csharp/System.Text/Encoding/Overview/Project.csproj @@ -0,0 +1,8 @@ + + + + Library + net10.0 + + + diff --git a/snippets/csharp/System.Text/Encoding/Overview/getencoding1.cs b/snippets/csharp/System.Text/Encoding/Overview/getencoding1.cs new file mode 100644 index 00000000000..3456efe6bf1 --- /dev/null +++ b/snippets/csharp/System.Text/Encoding/Overview/getencoding1.cs @@ -0,0 +1,90 @@ +// +using System; +using System.Text; + +public class Example +{ + public static void Main() + { + Encoding enc = Encoding.GetEncoding(1253); + Encoding altEnc = Encoding.GetEncoding("windows-1253"); + Console.WriteLine($"{enc.EncodingName} = Code Page {altEnc.CodePage}: {enc.Equals(altEnc)}"); + string greekAlphabet = "Α α Β β Γ γ Δ δ Ε ε Ζ ζ Η η " + + "Θ θ Ι ι Κ κ Λ λ Μ μ Ν ν Ξ ξ " + + "Ο ο Π π Ρ ρ Σ σ ς Τ τ Υ υ " + + "Φ φ Χ χ Ψ ψ Ω ω"; + Console.OutputEncoding = Encoding.UTF8; + byte[] bytes = enc.GetBytes(greekAlphabet); + Console.WriteLine("{0,-12} {1,20} {2,20:X2}", "Character", + "Unicode Code Point", "Code Page 1253"); + for (int ctr = 0; ctr < bytes.Length; ctr++) { + if (greekAlphabet[ctr].Equals(' ')) + continue; + + Console.WriteLine("{0,-12} {1,20} {2,20:X2}", greekAlphabet[ctr], + GetCodePoint(greekAlphabet[ctr]), bytes[ctr]); + } + } + + private static string GetCodePoint(char ch) + { + string retVal = "u+"; + byte[] bytes = Encoding.Unicode.GetBytes(ch.ToString()); + for (int ctr = bytes.Length - 1; ctr >= 0; ctr--) + retVal += bytes[ctr].ToString("X2"); + + return retVal; + } +} +// The example displays the following output: +// Character Unicode Code Point Code Page 1253 +// Α u+0391 C1 +// α u+03B1 E1 +// Β u+0392 C2 +// β u+03B2 E2 +// Γ u+0393 C3 +// γ u+03B3 E3 +// Δ u+0394 C4 +// δ u+03B4 E4 +// Ε u+0395 C5 +// ε u+03B5 E5 +// Ζ u+0396 C6 +// ζ u+03B6 E6 +// Η u+0397 C7 +// η u+03B7 E7 +// Θ u+0398 C8 +// θ u+03B8 E8 +// Ι u+0399 C9 +// ι u+03B9 E9 +// Κ u+039A CA +// κ u+03BA EA +// Λ u+039B CB +// λ u+03BB EB +// Μ u+039C CC +// μ u+03BC EC +// Ν u+039D CD +// ν u+03BD ED +// Ξ u+039E CE +// ξ u+03BE EE +// Ο u+039F CF +// ο u+03BF EF +// Π u+03A0 D0 +// π u+03C0 F0 +// Ρ u+03A1 D1 +// ρ u+03C1 F1 +// Σ u+03A3 D3 +// σ u+03C3 F3 +// ς u+03C2 F2 +// Τ u+03A4 D4 +// τ u+03C4 F4 +// Υ u+03A5 D5 +// υ u+03C5 F5 +// Φ u+03A6 D6 +// φ u+03C6 F6 +// Χ u+03A7 D7 +// χ u+03C7 F7 +// Ψ u+03A8 D8 +// ψ u+03C8 F8 +// Ω u+03A9 D9 +// ω u+03C9 F9 +// \ No newline at end of file diff --git a/snippets/csharp/System.Text/StringBuilder/Overview/Project.csproj b/snippets/csharp/System.Text/StringBuilder/Overview/Project.csproj new file mode 100644 index 00000000000..22dd9034898 --- /dev/null +++ b/snippets/csharp/System.Text/StringBuilder/Overview/Project.csproj @@ -0,0 +1,9 @@ + + + + Library + net10.0 + true + + + diff --git a/snippets/csharp/System.Text/StringBuilder/Overview/call1.cs b/snippets/csharp/System.Text/StringBuilder/Overview/call1.cs new file mode 100644 index 00000000000..ed96e1ca314 --- /dev/null +++ b/snippets/csharp/System.Text/StringBuilder/Overview/call1.cs @@ -0,0 +1,19 @@ +// +using System; +using System.Text; + +public class Example +{ + public static void Main() + { + StringBuilder sb = new StringBuilder(); + sb.Append("This is the beginning of a sentence, "); + sb.Replace("the beginning of ", ""); + sb.Insert(sb.ToString().IndexOf("a ") + 2, "complete "); + sb.Replace(",", "."); + Console.WriteLine(sb.ToString()); + } +} +// The example displays the following output: +// This is a complete sentence. +// diff --git a/snippets/csharp/System.Text/StringBuilder/Overview/call2.cs b/snippets/csharp/System.Text/StringBuilder/Overview/call2.cs new file mode 100644 index 00000000000..9fe17b881df --- /dev/null +++ b/snippets/csharp/System.Text/StringBuilder/Overview/call2.cs @@ -0,0 +1,17 @@ +// +using System; +using System.Text; + +public class Example2 +{ + public static void Main() + { + StringBuilder sb = new StringBuilder("This is the beginning of a sentence, "); + sb.Replace("the beginning of ", "").Insert(sb.ToString().IndexOf("a ") + 2, + "complete ").Replace(",", "."); + Console.WriteLine(sb.ToString()); + } +} +// The example displays the following output: +// This is a complete sentence. +// diff --git a/snippets/csharp/System.Text/StringBuilder/Overview/chars1.cs b/snippets/csharp/System.Text/StringBuilder/Overview/chars1.cs new file mode 100644 index 00000000000..85b3c3c6645 --- /dev/null +++ b/snippets/csharp/System.Text/StringBuilder/Overview/chars1.cs @@ -0,0 +1,46 @@ +// +using System; +using System.Globalization; +using System.Text; + +public class Example3 +{ + public static void Main() + { + Random rnd = new Random(); + StringBuilder sb = new StringBuilder(); + + // Generate 10 random numbers and store them in a StringBuilder. + for (int ctr = 0; ctr <= 9; ctr++) + sb.Append(rnd.Next().ToString("N5")); + + Console.WriteLine("The original string:"); + Console.WriteLine(sb.ToString()); + + // Decrease each number by one. + for (int ctr = 0; ctr < sb.Length; ctr++) + { + if (Char.GetUnicodeCategory(sb[ctr]) == UnicodeCategory.DecimalDigitNumber) + { + int number = (int)Char.GetNumericValue(sb[ctr]); + number--; + if (number < 0) number = 9; + + sb[ctr] = number.ToString()[0]; + } + } + Console.WriteLine("\nThe new string:"); + Console.WriteLine(sb.ToString()); + } +} +// The example displays the following output: +// The original string: +// 1,457,531,530.00000940,522,609.000001,668,113,564.000001,998,992,883.000001,792,660,834.00 +// 000101,203,251.000002,051,183,075.000002,066,000,067.000001,643,701,043.000001,702,382,508 +// .00000 +// +// The new string: +// 0,346,420,429.99999839,411,598.999990,557,002,453.999990,887,881,772.999990,681,559,723.99 +// 999090,192,140.999991,940,072,964.999991,955,999,956.999990,532,690,932.999990,691,271,497 +// .99999 +// diff --git a/snippets/csharp/System.Text/StringBuilder/Overview/default1.cs b/snippets/csharp/System.Text/StringBuilder/Overview/default1.cs new file mode 100644 index 00000000000..76998f10013 --- /dev/null +++ b/snippets/csharp/System.Text/StringBuilder/Overview/default1.cs @@ -0,0 +1,45 @@ +// +using System; +using System.Reflection; +using System.Text; + +public class Example4 +{ + public static void Main() + { + StringBuilder sb = new StringBuilder(); + ShowSBInfo(sb); + sb.Append("This is a sentence."); + ShowSBInfo(sb); + for (int ctr = 0; ctr <= 10; ctr++) + { + sb.Append("This is an additional sentence."); + ShowSBInfo(sb); + } + } + + private static void ShowSBInfo(StringBuilder sb) + { + foreach (var prop in sb.GetType().GetProperties()) + { + if (prop.GetIndexParameters().Length == 0) + Console.Write("{0}: {1:N0} ", prop.Name, prop.GetValue(sb)); + } + Console.WriteLine(); + } +} +// The example displays the following output: +// Capacity: 16 MaxCapacity: 2,147,483,647 Length: 0 +// Capacity: 32 MaxCapacity: 2,147,483,647 Length: 19 +// Capacity: 64 MaxCapacity: 2,147,483,647 Length: 50 +// Capacity: 128 MaxCapacity: 2,147,483,647 Length: 81 +// Capacity: 128 MaxCapacity: 2,147,483,647 Length: 112 +// Capacity: 256 MaxCapacity: 2,147,483,647 Length: 143 +// Capacity: 256 MaxCapacity: 2,147,483,647 Length: 174 +// Capacity: 256 MaxCapacity: 2,147,483,647 Length: 205 +// Capacity: 256 MaxCapacity: 2,147,483,647 Length: 236 +// Capacity: 512 MaxCapacity: 2,147,483,647 Length: 267 +// Capacity: 512 MaxCapacity: 2,147,483,647 Length: 298 +// Capacity: 512 MaxCapacity: 2,147,483,647 Length: 329 +// Capacity: 512 MaxCapacity: 2,147,483,647 Length: 360 +// diff --git a/snippets/csharp/System.Text/StringBuilder/Overview/delete1.cs b/snippets/csharp/System.Text/StringBuilder/Overview/delete1.cs new file mode 100644 index 00000000000..4d12e85f086 --- /dev/null +++ b/snippets/csharp/System.Text/StringBuilder/Overview/delete1.cs @@ -0,0 +1,44 @@ +// +using System; +using System.Text; + +public class Example5 +{ + public static void Main() + { + StringBuilder sb = new StringBuilder("A StringBuilder object"); + ShowSBInfo(sb); + // Remove "object" from the text. + string textToRemove = "object"; + int pos = sb.ToString().IndexOf(textToRemove); + if (pos >= 0) + { + sb.Remove(pos, textToRemove.Length); + ShowSBInfo(sb); + } + // Clear the StringBuilder contents. + sb.Clear(); + ShowSBInfo(sb); + } + + public static void ShowSBInfo(StringBuilder sb) + { + Console.WriteLine($"\nValue: {sb.ToString()}"); + foreach (var prop in sb.GetType().GetProperties()) + { + if (prop.GetIndexParameters().Length == 0) + Console.Write("{0}: {1:N0} ", prop.Name, prop.GetValue(sb)); + } + Console.WriteLine(); + } +} +// The example displays the following output: +// Value: A StringBuilder object +// Capacity: 22 MaxCapacity: 2,147,483,647 Length: 22 +// +// Value: A StringBuilder +// Capacity: 22 MaxCapacity: 2,147,483,647 Length: 16 +// +// Value: +// Capacity: 22 MaxCapacity: 2,147,483,647 Length: 0 +// diff --git a/snippets/csharp/System.Text/StringBuilder/Overview/expand1.cs b/snippets/csharp/System.Text/StringBuilder/Overview/expand1.cs new file mode 100644 index 00000000000..251766cd341 --- /dev/null +++ b/snippets/csharp/System.Text/StringBuilder/Overview/expand1.cs @@ -0,0 +1,49 @@ +// +using System; +using System.Text; + +public class Example6 +{ + public static void Main() + { + // Create a StringBuilder object with no text. + StringBuilder sb = new StringBuilder(); + // Append some text. + sb.Append('*', 10).Append(" Adding Text to a StringBuilder Object ").Append('*', 10); + sb.AppendLine("\n"); + sb.AppendLine("Some code points and their corresponding characters:"); + // Append some formatted text. + for (int ctr = 50; ctr <= 60; ctr++) + { + sb.AppendFormat("{0,12:X4} {1,12}", ctr, Convert.ToChar(ctr)); + sb.AppendLine(); + } + // Find the end of the introduction to the column. + int pos = sb.ToString().IndexOf("characters:") + 11 + + Environment.NewLine.Length; + // Insert a column header. + sb.Insert(pos, String.Format("{2}{0,12:X4} {1,12}{2}", "Code Unit", + "Character", "\n")); + + // Convert the StringBuilder to a string and display it. + Console.WriteLine(sb.ToString()); + } +} +// The example displays the following output: +// ********** Adding Text to a StringBuilder Object ********** +// +// Some code points and their corresponding characters: +// +// Code Unit Character +// 0032 2 +// 0033 3 +// 0034 4 +// 0035 5 +// 0036 6 +// 0037 7 +// 0038 8 +// 0039 9 +// 003A : +// 003B ; +// 003C < +// diff --git a/snippets/csharp/System.Text/StringBuilder/Overview/immutability2.cs b/snippets/csharp/System.Text/StringBuilder/Overview/immutability2.cs new file mode 100644 index 00000000000..1bdd80a7212 --- /dev/null +++ b/snippets/csharp/System.Text/StringBuilder/Overview/immutability2.cs @@ -0,0 +1,21 @@ +// +using System; + +public class Example7 +{ + public unsafe static void Main() + { + string value = "This is the first sentence" + "."; + fixed (char* start = value) + { + value = String.Concat(value, "This is the second sentence. "); + fixed (char* current = value) + { + Console.WriteLine(start == current); + } + } + } +} +// The example displays the following output: +// False +// diff --git a/snippets/csharp/System.Text/StringBuilder/Overview/instantiate1.cs b/snippets/csharp/System.Text/StringBuilder/Overview/instantiate1.cs new file mode 100644 index 00000000000..0d91bfb11e7 --- /dev/null +++ b/snippets/csharp/System.Text/StringBuilder/Overview/instantiate1.cs @@ -0,0 +1,48 @@ +// +using System; +using System.Text; + +public class Example8 +{ + public static void Main() + { + string value = "An ordinary string"; + int index = value.IndexOf("An ") + 3; + int capacity = 0xFFFF; + + // Instantiate a StringBuilder from a string. + StringBuilder sb1 = new StringBuilder(value); + ShowSBInfo(sb1); + + // Instantiate a StringBuilder from string and define a capacity. + StringBuilder sb2 = new StringBuilder(value, capacity); + ShowSBInfo(sb2); + + // Instantiate a StringBuilder from substring and define a capacity. + StringBuilder sb3 = new StringBuilder(value, index, + value.Length - index, + capacity); + ShowSBInfo(sb3); + } + + public static void ShowSBInfo(StringBuilder sb) + { + Console.WriteLine($"\nValue: {sb.ToString()}"); + foreach (var prop in sb.GetType().GetProperties()) + { + if (prop.GetIndexParameters().Length == 0) + Console.Write("{0}: {1:N0} ", prop.Name, prop.GetValue(sb)); + } + Console.WriteLine(); + } +} +// The example displays the following output: +// Value: An ordinary string +// Capacity: 18 MaxCapacity: 2,147,483,647 Length: 18 +// +// Value: An ordinary string +// Capacity: 65,535 MaxCapacity: 2,147,483,647 Length: 18 +// +// Value: ordinary string +// Capacity: 65,535 MaxCapacity: 2,147,483,647 Length: 15 +// diff --git a/snippets/csharp/System.Text/StringBuilder/Overview/pattern1.cs b/snippets/csharp/System.Text/StringBuilder/Overview/pattern1.cs new file mode 100644 index 00000000000..afb671908bd --- /dev/null +++ b/snippets/csharp/System.Text/StringBuilder/Overview/pattern1.cs @@ -0,0 +1,66 @@ +// +using System; +using System.Text; + +public class Example9 +{ + public static void Main() + { + Random rnd = new Random(); + string[] tempF = { "47.6F", "51.3F", "49.5F", "62.3F" }; + string[] tempC = { "21.2C", "16.1C", "23.5C", "22.9C" }; + string[][] temps = { tempF, tempC }; + + StringBuilder sb = new StringBuilder(); + var f = new StringBuilderFinder(sb, "F"); + var baseDate = new DateTime(2013, 5, 1); + String[] temperatures = temps[rnd.Next(2)]; + bool isFahrenheit = false; + foreach (var temperature in temperatures) + { + if (isFahrenheit) + sb.AppendFormat("{0:d}: {1}\n", baseDate, temperature); + else + isFahrenheit = f.SearchAndAppend(String.Format("{0:d}: {1}\n", + baseDate, temperature)); + baseDate = baseDate.AddDays(1); + } + if (isFahrenheit) + { + sb.Insert(0, "Average Daily Temperature in Degrees Fahrenheit"); + sb.Insert(47, "\n\n"); + } + else + { + sb.Insert(0, "Average Daily Temperature in Degrees Celsius"); + sb.Insert(44, "\n\n"); + } + Console.WriteLine(sb.ToString()); + } +} + +public class StringBuilderFinder +{ + private StringBuilder sb; + private String text; + + public StringBuilderFinder(StringBuilder sb, String textToFind) + { + this.sb = sb; + this.text = textToFind; + } + + public bool SearchAndAppend(String stringToSearch) + { + sb.Append(stringToSearch); + return stringToSearch.Contains(text); + } +} +// The example displays output similar to the following: +// Average Daily Temperature in Degrees Celsius +// +// 5/1/2013: 21.2C +// 5/2/2013: 16.1C +// 5/3/2013: 23.5C +// 5/4/2013: 22.9C +// diff --git a/snippets/csharp/System.Text/StringBuilder/Overview/pattern2.cs b/snippets/csharp/System.Text/StringBuilder/Overview/pattern2.cs new file mode 100644 index 00000000000..baa5e9f78d8 --- /dev/null +++ b/snippets/csharp/System.Text/StringBuilder/Overview/pattern2.cs @@ -0,0 +1,45 @@ +// +using System; +using System.Text; +using System.Text.RegularExpressions; + +public class Example10 +{ + public static void Main() + { + // Create a StringBuilder object with 4 successive occurrences + // of each character in the English alphabet. + StringBuilder sb = new StringBuilder(); + for (ushort ctr = (ushort)'a'; ctr <= (ushort)'z'; ctr++) + sb.Append(Convert.ToChar(ctr), 4); + + // Create a parallel string object. + String sbString = sb.ToString(); + // Determine where each new character sequence begins. + String pattern = @"(\w)\1+"; + MatchCollection matches = Regex.Matches(sbString, pattern); + + // Uppercase the first occurrence of the sequence, and separate it + // from the previous sequence by an underscore character. + for (int ctr = matches.Count - 1; ctr >= 0; ctr--) + { + Match m = matches[ctr]; + sb[m.Index] = Char.ToUpper(sb[m.Index]); + if (m.Index > 0) sb.Insert(m.Index, "_"); + } + // Display the resulting string. + sbString = sb.ToString(); + int line = 0; + do + { + int nChars = line * 80 + 79 <= sbString.Length ? + 80 : sbString.Length - line * 80; + Console.WriteLine(sbString.Substring(line * 80, nChars)); + line++; + } while (line * 80 < sbString.Length); + } +} +// The example displays the following output: +// Aaaa_Bbbb_Cccc_Dddd_Eeee_Ffff_Gggg_Hhhh_Iiii_Jjjj_Kkkk_Llll_Mmmm_Nnnn_Oooo_Pppp_ +// Qqqq_Rrrr_Ssss_Tttt_Uuuu_Vvvv_Wwww_Xxxx_Yyyy_Zzzz +// diff --git a/snippets/csharp/System.Text/StringBuilder/Overview/pattern3.cs b/snippets/csharp/System.Text/StringBuilder/Overview/pattern3.cs new file mode 100644 index 00000000000..4415ba820ca --- /dev/null +++ b/snippets/csharp/System.Text/StringBuilder/Overview/pattern3.cs @@ -0,0 +1,48 @@ +// +using System; +using System.Text; + +public class Example11 +{ + public static void Main() + { + // Create a StringBuilder object with 4 successive occurrences + // of each character in the English alphabet. + StringBuilder sb = new StringBuilder(); + for (ushort ctr = (ushort)'a'; ctr <= (ushort)'z'; ctr++) + sb.Append(Convert.ToChar(ctr), 4); + + // Iterate the text to determine when a new character sequence occurs. + int position = 0; + Char current = '\u0000'; + do + { + if (sb[position] != current) + { + current = sb[position]; + sb[position] = Char.ToUpper(sb[position]); + if (position > 0) + sb.Insert(position, "_"); + position += 2; + } + else + { + position++; + } + } while (position <= sb.Length - 1); + // Display the resulting string. + String sbString = sb.ToString(); + int line = 0; + do + { + int nChars = line * 80 + 79 <= sbString.Length ? + 80 : sbString.Length - line * 80; + Console.WriteLine(sbString.Substring(line * 80, nChars)); + line++; + } while (line * 80 < sbString.Length); + } +} +// The example displays the following output: +// Aaaa_Bbbb_Cccc_Dddd_Eeee_Ffff_Gggg_Hhhh_Iiii_Jjjj_Kkkk_Llll_Mmmm_Nnnn_Oooo_Pppp_ +// Qqqq_Rrrr_Ssss_Tttt_Uuuu_Vvvv_Wwww_Xxxx_Yyyy_Zzzz +// diff --git a/snippets/csharp/System.Text/StringBuilder/Overview/pattern4.cs b/snippets/csharp/System.Text/StringBuilder/Overview/pattern4.cs new file mode 100644 index 00000000000..c19bb283e94 --- /dev/null +++ b/snippets/csharp/System.Text/StringBuilder/Overview/pattern4.cs @@ -0,0 +1,41 @@ +// +using System; +using System.Text; +using System.Text.RegularExpressions; + +public class Example12 +{ + public static void Main() + { + // Create a StringBuilder object with 4 successive occurrences + // of each character in the English alphabet. + StringBuilder sb = new StringBuilder(); + for (ushort ctr = (ushort)'a'; ctr <= (ushort)'z'; ctr++) + sb.Append(Convert.ToChar(ctr), 4); + + // Convert it to a string. + String sbString = sb.ToString(); + + // Use a regex to uppercase the first occurrence of the sequence, + // and separate it from the previous sequence by an underscore. + string pattern = @"(\w)(\1+)"; + sbString = Regex.Replace(sbString, pattern, + m => (m.Index > 0 ? "_" : "") + + m.Groups[1].Value.ToUpper() + + m.Groups[2].Value); + + // Display the resulting string. + int line = 0; + do + { + int nChars = line * 80 + 79 <= sbString.Length ? + 80 : sbString.Length - line * 80; + Console.WriteLine(sbString.Substring(line * 80, nChars)); + line++; + } while (line * 80 < sbString.Length); + } +} +// The example displays the following output: +// Aaaa_Bbbb_Cccc_Dddd_Eeee_Ffff_Gggg_Hhhh_Iiii_Jjjj_Kkkk_Llll_Mmmm_Nnnn_Oooo_Pppp_ +// Qqqq_Rrrr_Ssss_Tttt_Uuuu_Vvvv_Wwww_Xxxx_Yyyy_Zzzz +// diff --git a/snippets/csharp/System.Text/StringBuilder/Overview/replace1.cs b/snippets/csharp/System.Text/StringBuilder/Overview/replace1.cs new file mode 100644 index 00000000000..10cbf950948 --- /dev/null +++ b/snippets/csharp/System.Text/StringBuilder/Overview/replace1.cs @@ -0,0 +1,16 @@ +// +using System; +using System.Text; + +public class Example13 +{ + public static void Main() + { + StringBuilder MyStringBuilder = new StringBuilder("Hello World!"); + MyStringBuilder.Replace('!', '?'); + Console.WriteLine(MyStringBuilder); + } +} +// The example displays the following output: +// Hello World? +// diff --git a/snippets/visualbasic/System.Text/Encoding/Overview/Project.vbproj b/snippets/visualbasic/System.Text/Encoding/Overview/Project.vbproj new file mode 100644 index 00000000000..874c98f3477 --- /dev/null +++ b/snippets/visualbasic/System.Text/Encoding/Overview/Project.vbproj @@ -0,0 +1,8 @@ + + + + Library + net10.0 + + + diff --git a/snippets/visualbasic/System.Text/Encoding/Overview/getencoding1.vb b/snippets/visualbasic/System.Text/Encoding/Overview/getencoding1.vb new file mode 100644 index 00000000000..864777764d9 --- /dev/null +++ b/snippets/visualbasic/System.Text/Encoding/Overview/getencoding1.vb @@ -0,0 +1,90 @@ +' Visual Basic .NET Document +Option Strict On + +' +Imports System.Text + +Module Example + Public Sub Main() + Dim enc As Encoding = Encoding.GetEncoding(1253) + Dim altEnc As Encoding = Encoding.GetEncoding("windows-1253") + Console.WriteLine("{0} = Code Page {1}: {2}", enc.EncodingName, + altEnc.CodePage, enc.Equals(altEnc)) + Dim greekAlphabet As String = "Α α Β β Γ γ Δ δ Ε ε Ζ ζ Η η " + + "Θ θ Ι ι Κ κ Λ λ Μ μ Ν ν Ξ ξ " + + "Ο ο Π π Ρ ρ Σ σ ς Τ τ Υ υ " + + "Φ φ Χ χ Ψ ψ Ω ω" + Console.OutputEncoding = Encoding.UTF8 + Dim bytes() As Byte = enc.GetBytes(greekAlphabet) + Console.WriteLine("{0,-12} {1,20} {2,20:X2}", "Character", + "Unicode Code Point", "Code Page 1253") + For ctr As Integer = 0 To bytes.Length - 1 + If greekAlphabet(ctr).Equals(" "c) Then Continue For + + Console.WriteLine("{0,-12} {1,20} {2,20:X2}", greekAlphabet(ctr), + GetCodePoint(greekAlphabet(ctr)), bytes(ctr)) + Next + + End Sub + + Private Function GetCodePoint(ch As String) As String + Dim retVal As String = "u+" + Dim bytes() As Byte = Encoding.Unicode.GetBytes(ch) + For ctr As Integer = bytes.Length - 1 To 0 Step -1 + retVal += bytes(ctr).ToString("X2") + Next + Return retVal + End Function +End Module +' The example displays the following output: +' Character Unicode Code Point Code Page 1253 +' Α u+0391 C1 +' α u+03B1 E1 +' Β u+0392 C2 +' β u+03B2 E2 +' Γ u+0393 C3 +' γ u+03B3 E3 +' Δ u+0394 C4 +' δ u+03B4 E4 +' Ε u+0395 C5 +' ε u+03B5 E5 +' Ζ u+0396 C6 +' ζ u+03B6 E6 +' Η u+0397 C7 +' η u+03B7 E7 +' Θ u+0398 C8 +' θ u+03B8 E8 +' Ι u+0399 C9 +' ι u+03B9 E9 +' Κ u+039A CA +' κ u+03BA EA +' Λ u+039B CB +' λ u+03BB EB +' Μ u+039C CC +' μ u+03BC EC +' Ν u+039D CD +' ν u+03BD ED +' Ξ u+039E CE +' ξ u+03BE EE +' Ο u+039F CF +' ο u+03BF EF +' Π u+03A0 D0 +' π u+03C0 F0 +' Ρ u+03A1 D1 +' ρ u+03C1 F1 +' Σ u+03A3 D3 +' σ u+03C3 F3 +' ς u+03C2 F2 +' Τ u+03A4 D4 +' τ u+03C4 F4 +' Υ u+03A5 D5 +' υ u+03C5 F5 +' Φ u+03A6 D6 +' φ u+03C6 F6 +' Χ u+03A7 D7 +' χ u+03C7 F7 +' Ψ u+03A8 D8 +' ψ u+03C8 F8 +' Ω u+03A9 D9 +' ω u+03C9 F9 +' diff --git a/snippets/visualbasic/System.Text/StringBuilder/Overview/Project.vbproj b/snippets/visualbasic/System.Text/StringBuilder/Overview/Project.vbproj new file mode 100644 index 00000000000..874c98f3477 --- /dev/null +++ b/snippets/visualbasic/System.Text/StringBuilder/Overview/Project.vbproj @@ -0,0 +1,8 @@ + + + + Library + net10.0 + + + diff --git a/snippets/visualbasic/System.Text/StringBuilder/Overview/call1.vb b/snippets/visualbasic/System.Text/StringBuilder/Overview/call1.vb new file mode 100644 index 00000000000..71c9e10dac0 --- /dev/null +++ b/snippets/visualbasic/System.Text/StringBuilder/Overview/call1.vb @@ -0,0 +1,19 @@ +' Visual Basic .NET Document +Option Strict On + +' +Imports System.Text + +Module Example2 + Public Sub Main() + Dim sb As New StringBuilder() + sb.Append("This is the beginning of a sentence, ") + sb.Replace("the beginning of ", "") + sb.Insert(sb.ToString().IndexOf("a ") + 2, "complete ") + sb.Replace(",", ".") + Console.WriteLine(sb.ToString()) + End Sub +End Module +' The example displays the following output: +' This is a complete sentence. +' diff --git a/snippets/visualbasic/System.Text/StringBuilder/Overview/call2.vb b/snippets/visualbasic/System.Text/StringBuilder/Overview/call2.vb new file mode 100644 index 00000000000..358d0a456b4 --- /dev/null +++ b/snippets/visualbasic/System.Text/StringBuilder/Overview/call2.vb @@ -0,0 +1,17 @@ +' Visual Basic .NET Document +Option Strict On + +' +Imports System.Text + +Module Example3 + Public Sub Main() + Dim sb As New StringBuilder("This is the beginning of a sentence, ") + sb.Replace("the beginning of ", "").Insert(sb.ToString().IndexOf("a ") + 2, + "complete ").Replace(", ", ".") + Console.WriteLine(sb.ToString()) + End Sub +End Module +' The example displays the following output: +' This is a complete sentence. +' diff --git a/snippets/visualbasic/System.Text/StringBuilder/Overview/chars1.vb b/snippets/visualbasic/System.Text/StringBuilder/Overview/chars1.vb new file mode 100644 index 00000000000..68f7824256a --- /dev/null +++ b/snippets/visualbasic/System.Text/StringBuilder/Overview/chars1.vb @@ -0,0 +1,46 @@ +' Visual Basic .NET Document +Option Strict On + +' +Imports System.Globalization +Imports System.Text + +Module Example4 + Public Sub Main() + Dim rnd As New Random() + Dim sb As New StringBuilder() + + ' Generate 10 random numbers and store them in a StringBuilder. + For ctr As Integer = 0 To 9 + sb.Append(rnd.Next().ToString("N5")) + Next + Console.WriteLine("The original string:") + Console.WriteLine(sb.ToString()) + Console.WriteLine() + + ' Decrease each number by one. + For ctr As Integer = 0 To sb.Length - 1 + If Char.GetUnicodeCategory(sb(ctr)) = UnicodeCategory.DecimalDigitNumber Then + Dim number As Integer = CType(Char.GetNumericValue(sb(ctr)), Integer) + number -= 1 + If number < 0 Then number = 9 + + sb(ctr) = number.ToString()(0) + End If + Next + Console.WriteLine("The new string:") + Console.WriteLine(sb.ToString()) + End Sub +End Module +' The example displays the following output: +' The original string: +' 1,457,531,530.00000940,522,609.000001,668,113,564.000001,998,992,883.000001,792,660,834.00 +' 000101,203,251.000002,051,183,075.000002,066,000,067.000001,643,701,043.000001,702,382,508 +' .00000 +' +' The new string: +' 0,346,420,429.99999839,411,598.999990,557,002,453.999990,887,881,772.999990,681,559,723.99 +' 999090,192,140.999991,940,072,964.999991,955,999,956.999990,532,690,932.999990,691,271,497 +' .99999 +' + diff --git a/snippets/visualbasic/System.Text/StringBuilder/Overview/default1.vb b/snippets/visualbasic/System.Text/StringBuilder/Overview/default1.vb new file mode 100644 index 00000000000..60388e491b3 --- /dev/null +++ b/snippets/visualbasic/System.Text/StringBuilder/Overview/default1.vb @@ -0,0 +1,43 @@ +' Visual Basic .NET Document +Option Strict On + +' +Imports System.Reflection +Imports System.Text + +Module Example5 + Public Sub Main() + Dim sb As New StringBuilder() + ShowSBInfo(sb) + sb.Append("This is a sentence.") + ShowSBInfo(sb) + For ctr As Integer = 0 To 10 + sb.Append("This is an additional sentence.") + ShowSBInfo(sb) + Next + End Sub + + Public Sub ShowSBInfo(sb As StringBuilder) + For Each prop In sb.GetType().GetProperties + If prop.GetIndexParameters().Length = 0 Then + Console.Write("{0}: {1:N0} ", prop.Name, prop.GetValue(sb)) + End If + Next + Console.WriteLine() + End Sub +End Module +' The example displays the following output: +' Capacity: 16 MaxCapacity: 2,147,483,647 Length: 0 +' Capacity: 32 MaxCapacity: 2,147,483,647 Length: 19 +' Capacity: 64 MaxCapacity: 2,147,483,647 Length: 50 +' Capacity: 128 MaxCapacity: 2,147,483,647 Length: 81 +' Capacity: 128 MaxCapacity: 2,147,483,647 Length: 112 +' Capacity: 256 MaxCapacity: 2,147,483,647 Length: 143 +' Capacity: 256 MaxCapacity: 2,147,483,647 Length: 174 +' Capacity: 256 MaxCapacity: 2,147,483,647 Length: 205 +' Capacity: 256 MaxCapacity: 2,147,483,647 Length: 236 +' Capacity: 512 MaxCapacity: 2,147,483,647 Length: 267 +' Capacity: 512 MaxCapacity: 2,147,483,647 Length: 298 +' Capacity: 512 MaxCapacity: 2,147,483,647 Length: 329 +' Capacity: 512 MaxCapacity: 2,147,483,647 Length: 360 +' diff --git a/snippets/visualbasic/System.Text/StringBuilder/Overview/delete1.vb b/snippets/visualbasic/System.Text/StringBuilder/Overview/delete1.vb new file mode 100644 index 00000000000..905d4bd6f64 --- /dev/null +++ b/snippets/visualbasic/System.Text/StringBuilder/Overview/delete1.vb @@ -0,0 +1,44 @@ +' Visual Basic .NET Document +Option Strict On + +' +Imports System.Text + +Module Example6 + Public Sub Main() + Dim sb As New StringBuilder("A StringBuilder object") + ShowSBInfo(sb) + ' Remove "object" from the text. + Dim textToRemove As String = "object" + Dim pos As Integer = sb.ToString().IndexOf(textToRemove) + If pos >= 0 Then + sb.Remove(pos, textToRemove.Length) + ShowSBInfo(sb) + End If + ' Clear the StringBuilder contents. + sb.Clear() + ShowSBInfo(sb) + End Sub + + Public Sub ShowSBInfo(sb As StringBuilder) + Console.WriteLine() + Console.WriteLine("Value: {0}", sb.ToString()) + For Each prop In sb.GetType().GetProperties + If prop.GetIndexParameters().Length = 0 Then + Console.Write("{0}: {1:N0} ", prop.Name, prop.GetValue(sb)) + End If + Next + Console.WriteLine() + End Sub +End Module +' The example displays the following output: +' Value: A StringBuilder object +' Capacity: 22 MaxCapacity: 2,147,483,647 Length: 22 +' +' Value: A StringBuilder +' Capacity: 22 MaxCapacity: 2,147,483,647 Length: 16 +' +' Value: +' Capacity: 22 MaxCapacity: 2,147,483,647 Length: 0 +' + diff --git a/snippets/visualbasic/System.Text/StringBuilder/Overview/expand1.vb b/snippets/visualbasic/System.Text/StringBuilder/Overview/expand1.vb new file mode 100644 index 00000000000..21b2eee5489 --- /dev/null +++ b/snippets/visualbasic/System.Text/StringBuilder/Overview/expand1.vb @@ -0,0 +1,49 @@ +' Visual Basic .NET Document +Option Strict On + +' +Imports System.Text + +Module Example7 + Public Sub Main() + ' Create a StringBuilder object with no text. + Dim sb As New StringBuilder() + ' Append some text. + sb.Append("*"c, 10).Append(" Adding Text to a StringBuilder Object ").Append("*"c, 10) + sb.AppendLine() + sb.AppendLine() + sb.AppendLine("Some code points and their corresponding characters:") + ' Append some formatted text. + For ctr = 50 To 60 + sb.AppendFormat("{0,12:X4} {1,12}", ctr, Convert.ToChar(ctr)) + sb.AppendLine() + Next + ' Find the end of the introduction to the column. + Dim pos As Integer = sb.ToString().IndexOf("characters:") + 11 + + Environment.NewLine.Length + ' Insert a column header. + sb.Insert(pos, String.Format("{2}{0,12:X4} {1,12}{2}", "Code Unit", + "Character", vbCrLf)) + + ' Convert the StringBuilder to a string and display it. + Console.WriteLine(sb.ToString()) + End Sub +End Module +' The example displays the following output: +' ********** Adding Text to a StringBuilder Object ********** +' +' Some code points and their corresponding characters: +' +' Code Unit Character +' 0032 2 +' 0033 3 +' 0034 4 +' 0035 5 +' 0036 6 +' 0037 7 +' 0038 8 +' 0039 9 +' 003A : +' 003B ; +' 003C < +' diff --git a/snippets/visualbasic/System.Text/StringBuilder/Overview/instantiate1.vb b/snippets/visualbasic/System.Text/StringBuilder/Overview/instantiate1.vb new file mode 100644 index 00000000000..a2ecb1f9a8c --- /dev/null +++ b/snippets/visualbasic/System.Text/StringBuilder/Overview/instantiate1.vb @@ -0,0 +1,49 @@ +' Visual Basic .NET Document +Option Strict On + +' +Imports System.Text + +Module Example8 + Public Sub Main() + Dim value As String = "An ordinary string" + Dim index As Integer = value.IndexOf("An ") + 3 + Dim capacity As Integer = &HFFFF + + ' Instantiate a StringBuilder from a string. + Dim sb1 As New StringBuilder(value) + ShowSBInfo(sb1) + + ' Instantiate a StringBuilder from string and define a capacity. + Dim sb2 As New StringBuilder(value, capacity) + ShowSBInfo(sb2) + + ' Instantiate a StringBuilder from substring and define a capacity. + Dim sb3 As New StringBuilder(value, index, + value.Length - index, + capacity) + ShowSBInfo(sb3) + End Sub + + Public Sub ShowSBInfo(sb As StringBuilder) + Console.WriteLine() + Console.WriteLine("Value: {0}", sb.ToString()) + For Each prop In sb.GetType().GetProperties + If prop.GetIndexParameters().Length = 0 Then + Console.Write("{0}: {1:N0} ", prop.Name, prop.GetValue(sb)) + End If + Next + Console.WriteLine() + End Sub +End Module +' The example displays the following output: +' Value: An ordinary string +' Capacity: 18 MaxCapacity: 2,147,483,647 Length: 18 +' +' Value: An ordinary string +' Capacity: 65,535 MaxCapacity: 2,147,483,647 Length: 18 +' +' Value: ordinary string +' Capacity: 65,535 MaxCapacity: 2,147,483,647 Length: 15 +' + diff --git a/snippets/visualbasic/System.Text/StringBuilder/Overview/pattern1.vb b/snippets/visualbasic/System.Text/StringBuilder/Overview/pattern1.vb new file mode 100644 index 00000000000..bfef80bcabc --- /dev/null +++ b/snippets/visualbasic/System.Text/StringBuilder/Overview/pattern1.vb @@ -0,0 +1,60 @@ +' Visual Basic .NET Document +Option Strict On + +' +Imports System.Text + +Module Example9 + Public Sub Main() + Dim rnd As New Random() + Dim tempF() As String = {"47.6F", "51.3F", "49.5F", "62.3F"} + Dim tempC() As String = {"21.2C", "16.1C", "23.5C", "22.9C"} + Dim temps()() As String = {tempF, tempC} + + Dim sb As StringBuilder = New StringBuilder() + Dim f As New StringBuilderFinder(sb, "F") + Dim baseDate As New DateTime(2013, 5, 1) + Dim temperatures() As String = temps(rnd.Next(2)) + Dim isFahrenheit As Boolean = False + For Each temperature In temperatures + If isFahrenheit Then + sb.AppendFormat("{0:d}: {1}{2}", baseDate, temperature, vbCrLf) + Else + isFahrenheit = f.SearchAndAppend(String.Format("{0:d}: {1}{2}", + baseDate, temperature, vbCrLf)) + End If + baseDate = baseDate.AddDays(1) + Next + If isFahrenheit Then + sb.Insert(0, "Average Daily Temperature in Degrees Fahrenheit") + sb.Insert(47, vbCrLf + vbCrLf) + Else + sb.Insert(0, "Average Daily Temperature in Degrees Celsius") + sb.Insert(44, vbCrLf + vbCrLf) + End If + Console.WriteLine(sb.ToString()) + End Sub +End Module + +Public Class StringBuilderFinder + Private sb As StringBuilder + Private text As String + + Public Sub New(sb As StringBuilder, textToFind As String) + Me.sb = sb + text = textToFind + End Sub + + Public Function SearchAndAppend(stringToSearch As String) As Boolean + sb.Append(stringToSearch) + Return stringToSearch.Contains(text) + End Function +End Class +' The example displays output similar to the following: +' Average Daily Temperature in Degrees Celsius +' +' 5/1/2013: 21.2C +' 5/2/2013: 16.1C +' 5/3/2013: 23.5C +' 5/4/2013: 22.9C +' diff --git a/snippets/visualbasic/System.Text/StringBuilder/Overview/pattern2.vb b/snippets/visualbasic/System.Text/StringBuilder/Overview/pattern2.vb new file mode 100644 index 00000000000..0fa2ece1e7b --- /dev/null +++ b/snippets/visualbasic/System.Text/StringBuilder/Overview/pattern2.vb @@ -0,0 +1,43 @@ +' Visual Basic .NET Document +Option Strict On + +' +Imports System.Text +Imports System.Text.RegularExpressions + +Module Example10 + Public Sub Main() + ' Create a StringBuilder object with 4 successive occurrences + ' of each character in the English alphabet. + Dim sb As New StringBuilder() + For ctr As UShort = AscW("a") To AscW("z") + sb.Append(ChrW(ctr), 4) + Next + ' Create a parallel string object. + Dim sbString As String = sb.ToString() + ' Determine where each new character sequence begins. + Dim pattern As String = "(\w)\1+" + Dim matches As MatchCollection = Regex.Matches(sbString, pattern) + + ' Uppercase the first occurrence of the sequence, and separate it + ' from the previous sequence by an underscore character. + For ctr As Integer = matches.Count - 1 To 0 Step -1 + Dim m As Match = matches(ctr) + sb.Chars(m.Index) = Char.ToUpper(sb.Chars(m.Index)) + If m.Index > 0 Then sb.Insert(m.Index, "_") + Next + ' Display the resulting string. + sbString = sb.ToString() + Dim line As Integer = 0 + Do + Dim nChars As Integer = If(line * 80 + 79 <= sbString.Length, + 80, sbString.Length - line * 80) + Console.WriteLine(sbString.Substring(line * 80, nChars)) + line += 1 + Loop While line * 80 < sbString.Length + End Sub +End Module +' The example displays the following output: +' Aaaa_Bbbb_Cccc_Dddd_Eeee_Ffff_Gggg_Hhhh_Iiii_Jjjj_Kkkk_Llll_Mmmm_Nnnn_Oooo_Pppp_ +' Qqqq_Rrrr_Ssss_Tttt_Uuuu_Vvvv_Wwww_Xxxx_Yyyy_Zzzz +' diff --git a/snippets/visualbasic/System.Text/StringBuilder/Overview/pattern3.vb b/snippets/visualbasic/System.Text/StringBuilder/Overview/pattern3.vb new file mode 100644 index 00000000000..7ecbaa54107 --- /dev/null +++ b/snippets/visualbasic/System.Text/StringBuilder/Overview/pattern3.vb @@ -0,0 +1,42 @@ +' Visual Basic .NET Document +Option Strict On + +' +Imports System.Text + +Module Example11 + Public Sub Main() + ' Create a StringBuilder object with 4 successive occurrences + ' of each character in the English alphabet. + Dim sb As New StringBuilder() + For ctr As UShort = AscW("a") To AscW("z") + sb.Append(ChrW(ctr), 4) + Next + ' Iterate the text to determine when a new character sequence occurs. + Dim position As Integer = 0 + Dim current As Char = ChrW(0) + Do + If sb(position) <> current Then + current = sb(position) + sb(position) = Char.ToUpper(sb(position)) + If position > 0 Then sb.Insert(position, "_") + position += 2 + Else + position += 1 + End If + Loop While position <= sb.Length - 1 + ' Display the resulting string. + Dim sbString As String = sb.ToString() + Dim line As Integer = 0 + Do + Dim nChars As Integer = If(line * 80 + 79 <= sbString.Length, + 80, sbString.Length - line * 80) + Console.WriteLine(sbString.Substring(line * 80, nChars)) + line += 1 + Loop While line * 80 < sbString.Length + End Sub +End Module +' The example displays the following output: +' Aaaa_Bbbb_Cccc_Dddd_Eeee_Ffff_Gggg_Hhhh_Iiii_Jjjj_Kkkk_Llll_Mmmm_Nnnn_Oooo_Pppp_ +' Qqqq_Rrrr_Ssss_Tttt_Uuuu_Vvvv_Wwww_Xxxx_Yyyy_Zzzz +' diff --git a/snippets/visualbasic/System.Text/StringBuilder/Overview/pattern4.vb b/snippets/visualbasic/System.Text/StringBuilder/Overview/pattern4.vb new file mode 100644 index 00000000000..9fb52dbd596 --- /dev/null +++ b/snippets/visualbasic/System.Text/StringBuilder/Overview/pattern4.vb @@ -0,0 +1,40 @@ +' Visual Basic .NET Document +Option Strict On + +' +Imports System.Text +Imports System.Text.RegularExpressions + +Module Example12 + Public Sub Main() + ' Create a StringBuilder object with 4 successive occurrences + ' of each character in the English alphabet. + Dim sb As New StringBuilder() + For ctr As UShort = AscW("a") To AscW("z") + sb.Append(ChrW(ctr), 4) + Next + ' Convert it to a string. + Dim sbString As String = sb.ToString() + + ' Use a regex to uppercase the first occurrence of the sequence, + ' and separate it from the previous sequence by an underscore. + Dim pattern As String = "(\w)(\1+)" + sbString = Regex.Replace(sbString, pattern, + Function(m) If(m.Index > 0, "_", "") + + m.Groups(1).Value.ToUpper + + m.Groups(2).Value) + + ' Display the resulting string. + Dim line As Integer = 0 + Do + Dim nChars As Integer = If(line * 80 + 79 <= sbString.Length, + 80, sbString.Length - line * 80) + Console.WriteLine(sbString.Substring(line * 80, nChars)) + line += 1 + Loop While line * 80 < sbString.Length + End Sub +End Module +' The example displays the following output: +' Aaaa_Bbbb_Cccc_Dddd_Eeee_Ffff_Gggg_Hhhh_Iiii_Jjjj_Kkkk_Llll_Mmmm_Nnnn_Oooo_Pppp_ +' Qqqq_Rrrr_Ssss_Tttt_Uuuu_Vvvv_Wwww_Xxxx_Yyyy_Zzzz +' diff --git a/snippets/visualbasic/System.Text/StringBuilder/Overview/replace1.vb b/snippets/visualbasic/System.Text/StringBuilder/Overview/replace1.vb new file mode 100644 index 00000000000..7da78f82ca4 --- /dev/null +++ b/snippets/visualbasic/System.Text/StringBuilder/Overview/replace1.vb @@ -0,0 +1,16 @@ +' Visual Basic .NET Document +Option Strict On + +' +Imports System.Text + +Module Example + Public Sub Main() + Dim MyStringBuilder As New StringBuilder("Hello World!") + MyStringBuilder.Replace("!"c, "?"c) + Console.WriteLine(MyStringBuilder) + End Sub +End Module +' The example displays the following output: +' Hello World? +' diff --git a/snippets/visualbasic/System.Threading.Tasks/Task/Overview/Project.vbproj b/snippets/visualbasic/System.Threading.Tasks/Task/Overview/Project.vbproj new file mode 100644 index 00000000000..874c98f3477 --- /dev/null +++ b/snippets/visualbasic/System.Threading.Tasks/Task/Overview/Project.vbproj @@ -0,0 +1,8 @@ + + + + Library + net10.0 + + + diff --git a/snippets/visualbasic/System.Threading.Tasks/Task/Overview/Wait1.vb b/snippets/visualbasic/System.Threading.Tasks/Task/Overview/Wait1.vb new file mode 100644 index 00000000000..914b7bce249 --- /dev/null +++ b/snippets/visualbasic/System.Threading.Tasks/Task/Overview/Wait1.vb @@ -0,0 +1,24 @@ +' Visual Basic .NET Document +Option Strict On + +' +Imports System.Threading +Imports System.Threading.Tasks + +Module Example4 + Public Sub Main() + ' Wait on a single task with no timeout specified. + Dim taskA = Task.Run(Sub() Thread.Sleep(2000)) + Console.WriteLine("taskA Status: {0}", taskA.Status) + Try + taskA.Wait() + Console.WriteLine("taskA Status: {0}", taskA.Status) + Catch e As AggregateException + Console.WriteLine("Exception in taskA.") + End Try + End Sub +End Module +' The example displays output like the following: +' taskA Status: WaitingToRun +' taskA Status: RanToCompletion +' diff --git a/snippets/visualbasic/System.Threading.Tasks/Task/Overview/Wait2.vb b/snippets/visualbasic/System.Threading.Tasks/Task/Overview/Wait2.vb new file mode 100644 index 00000000000..5831bede59b --- /dev/null +++ b/snippets/visualbasic/System.Threading.Tasks/Task/Overview/Wait2.vb @@ -0,0 +1,28 @@ +' Visual Basic .NET Document +Option Strict On + +' +Imports System.Threading +Imports System.Threading.Tasks + +Module Example5 + Public Sub Main() + ' Wait on a single task with a timeout specified. + Dim taskA As Task = Task.Run(Sub() Thread.Sleep(2000)) + Try + taskA.Wait(1000) ' Wait for 1 second. + Dim completed As Boolean = taskA.IsCompleted + Console.WriteLine("Task.Completed: {0}, Status: {1}", + completed, taskA.Status) + If Not completed Then + Console.WriteLine("Timed out before task A completed.") + End If + Catch e As AggregateException + Console.WriteLine("Exception in taskA.") + End Try + End Sub +End Module +' The example displays the following output: +' Task A completed: False, Status: Running +' Timed out before task A completed. +' diff --git a/snippets/visualbasic/System.Threading.Tasks/Task/Overview/WaitAll1.vb b/snippets/visualbasic/System.Threading.Tasks/Task/Overview/WaitAll1.vb new file mode 100644 index 00000000000..fc512ca31a2 --- /dev/null +++ b/snippets/visualbasic/System.Threading.Tasks/Task/Overview/WaitAll1.vb @@ -0,0 +1,42 @@ +' Visual Basic .NET Document +Option Strict On + +' +Imports System.Threading +Imports System.Threading.Tasks + +Module Example6 + Public Sub Main() + ' Wait for all tasks to complete. + Dim tasks(9) As Task + For i As Integer = 0 To 9 + tasks(i) = Task.Run(Sub() Thread.Sleep(2000)) + Next + Try + Task.WaitAll(tasks) + Catch ae As AggregateException + Console.WriteLine("One or more exceptions occurred: ") + For Each ex In ae.Flatten().InnerExceptions + Console.WriteLine(" {0}", ex.Message) + Next + End Try + + Console.WriteLine("Status of completed tasks:") + For Each t In tasks + Console.WriteLine(" Task #{0}: {1}", t.Id, t.Status) + Next + End Sub +End Module +' The example displays the following output: +' Status of completed tasks: +' Task #2: RanToCompletion +' Task #1: RanToCompletion +' Task #3: RanToCompletion +' Task #4: RanToCompletion +' Task #6: RanToCompletion +' Task #5: RanToCompletion +' Task #7: RanToCompletion +' Task #8: RanToCompletion +' Task #9: RanToCompletion +' Task #10: RanToCompletion +' diff --git a/snippets/visualbasic/System.Threading.Tasks/Task/Overview/WaitAll2.vb b/snippets/visualbasic/System.Threading.Tasks/Task/Overview/WaitAll2.vb new file mode 100644 index 00000000000..91cea251e4b --- /dev/null +++ b/snippets/visualbasic/System.Threading.Tasks/Task/Overview/WaitAll2.vb @@ -0,0 +1,98 @@ +' Visual Basic .NET Document +Option Strict On + +' +Imports System.Threading +Imports System.Threading.Tasks + +Module Example7 + Public Sub Main() + ' Create a cancellation token and cancel it. + Dim source1 As New CancellationTokenSource() + Dim token1 As CancellationToken = source1.Token + source1.Cancel() + ' Create a cancellation token for later cancellation. + Dim source2 As New CancellationTokenSource() + Dim token2 As CancellationToken = source2.Token + + ' Create a series of tasks that will complete, be cancelled, + ' timeout, or throw an exception. + Dim tasks(11) As Task + For i As Integer = 0 To 11 + Select Case i Mod 4 + ' Task should run to completion. + Case 0 + tasks(i) = Task.Run(Sub() Thread.Sleep(2000)) + ' Task should be set to canceled state. + Case 1 + tasks(i) = Task.Run(Sub() Thread.Sleep(2000), token1) + Case 2 + ' Task should throw an exception. + tasks(i) = Task.Run(Sub() + Throw New NotSupportedException() + End Sub) + Case 3 + ' Task should examine cancellation token. + tasks(i) = Task.Run(Sub() + Thread.Sleep(2000) + If token2.IsCancellationRequested Then + token2.ThrowIfCancellationRequested() + End If + Thread.Sleep(500) + End Sub, token2) + End Select + Next + Thread.Sleep(250) + source2.Cancel() + + Try + Task.WaitAll(tasks) + Catch ae As AggregateException + Console.WriteLine("One or more exceptions occurred:") + For Each ex In ae.InnerExceptions + Console.WriteLine(" {0}: {1}", ex.GetType().Name, ex.Message) + Next + End Try + Console.WriteLine() + + Console.WriteLine("Status of tasks:") + For Each t In tasks + Console.WriteLine(" Task #{0}: {1}", t.Id, t.Status) + If t.Exception IsNot Nothing Then + For Each ex In t.Exception.InnerExceptions + Console.WriteLine(" {0}: {1}", ex.GetType().Name, + ex.Message) + Next + End If + Next + End Sub +End Module +' The example displays output like the following: +' One or more exceptions occurred: +' TaskCanceledException: A task was canceled. +' NotSupportedException: Specified method is not supported. +' TaskCanceledException: A task was canceled. +' TaskCanceledException: A task was canceled. +' NotSupportedException: Specified method is not supported. +' TaskCanceledException: A task was canceled. +' TaskCanceledException: A task was canceled. +' NotSupportedException: Specified method is not supported. +' TaskCanceledException: A task was canceled. +' +' Status of tasks: +' Task #13: RanToCompletion +' Task #1: Canceled +' Task #3: Faulted +' NotSupportedException: Specified method is not supported. +' Task #8: Canceled +' Task #14: RanToCompletion +' Task #4: Canceled +' Task #6: Faulted +' NotSupportedException: Specified method is not supported. +' Task #7: Canceled +' Task #15: RanToCompletion +' Task #9: Canceled +' Task #11: Faulted +' NotSupportedException: Specified method is not supported. +' Task #12: Canceled +' diff --git a/snippets/visualbasic/System.Threading.Tasks/Task/Overview/WaitAny1.vb b/snippets/visualbasic/System.Threading.Tasks/Task/Overview/WaitAny1.vb new file mode 100644 index 00000000000..6efb896788c --- /dev/null +++ b/snippets/visualbasic/System.Threading.Tasks/Task/Overview/WaitAny1.vb @@ -0,0 +1,35 @@ +' Visual Basic .NET Document +Option Strict On + +' +Imports System.Threading + +Module Example8 + Public Sub Main() + Dim tasks(2) As Task + Dim rnd As New Random() + For ctr As Integer = 0 To 2 + tasks(ctr) = Task.Run(Sub() Thread.Sleep(rnd.Next(500, 3000))) + Next + + Try + Dim index As Integer = Task.WaitAny(tasks) + Console.WriteLine("Task #{0} completed first.", tasks(index).Id) + Console.WriteLine() + Console.WriteLine("Status of all tasks:") + For Each t In tasks + Console.WriteLine(" Task #{0}: {1}", t.Id, t.Status) + Next + Catch e As AggregateException + Console.WriteLine("An exception occurred.") + End Try + End Sub +End Module +' The example displays output like the following: +' Task #1 completed first. +' +' Status of all tasks: +' Task #3: Running +' Task #1: RanToCompletion +' Task #4: Running +' diff --git a/snippets/visualbasic/System.Threading.Tasks/Task/Overview/run1.vb b/snippets/visualbasic/System.Threading.Tasks/Task/Overview/run1.vb new file mode 100644 index 00000000000..1c5ed25f062 --- /dev/null +++ b/snippets/visualbasic/System.Threading.Tasks/Task/Overview/run1.vb @@ -0,0 +1,22 @@ +' Visual Basic .NET Document +Option Strict On + +' +Imports System.Threading.Tasks + +Module Example1 + Public Sub Main() + Dim t As Task = Task.Run(Sub() + ' Just loop. + Dim ctr As Integer = 0 + For ctr = 0 To 1000000 + Next + Console.WriteLine("Finished {0} loop iterations", + ctr) + End Sub) + t.Wait() + End Sub +End Module +' The example displays the following output: +' Finished 1000001 loop iterations +' diff --git a/snippets/visualbasic/System.Threading.Tasks/Task/Overview/startnew.vb b/snippets/visualbasic/System.Threading.Tasks/Task/Overview/startnew.vb new file mode 100644 index 00000000000..855e0f8297b --- /dev/null +++ b/snippets/visualbasic/System.Threading.Tasks/Task/Overview/startnew.vb @@ -0,0 +1,54 @@ +' +Imports System.Threading +Imports System.Threading.Tasks + +Module Example2 + Public Sub Main() + Dim action As Action(Of Object) = + Sub(obj As Object) + Console.WriteLine("Task={0}, obj={1}, Thread={2}", + Task.CurrentId, obj, + Thread.CurrentThread.ManagedThreadId) + End Sub + + ' Construct an unstarted task + Dim t1 As New Task(action, "alpha") + + ' Construct a started task + Dim t2 As Task = Task.Factory.StartNew(action, "beta") + ' Block the main thread to demonstrate that t2 is executing + t2.Wait() + + ' Launch t1 + t1.Start() + Console.WriteLine("t1 has been launched. (Main Thread={0})", + Thread.CurrentThread.ManagedThreadId) + ' Wait for the task to finish. + t1.Wait() + + ' Construct a started task using Task.Run. + Dim taskData As String = "delta" + Dim t3 As Task = Task.Run(Sub() + Console.WriteLine("Task={0}, obj={1}, Thread={2}", + Task.CurrentId, taskData, + Thread.CurrentThread.ManagedThreadId) + End Sub) + ' Wait for the task to finish. + t3.Wait() + + ' Construct an unstarted task + Dim t4 As New Task(action, "gamma") + ' Run it synchronously + t4.RunSynchronously() + ' Although the task was run synchronously, it is a good practice + ' to wait for it in the event exceptions were thrown by the task. + t4.Wait() + End Sub +End Module +' The example displays output like the following: +' Task=1, obj=beta, Thread=3 +' t1 has been launched. (Main Thread=1) +' Task=2, obj=alpha, Thread=3 +' Task=3, obj=delta, Thread=3 +' Task=4, obj=gamma, Thread=1 +' diff --git a/snippets/visualbasic/System.Threading.Tasks/Task/Overview/startnew1.vb b/snippets/visualbasic/System.Threading.Tasks/Task/Overview/startnew1.vb new file mode 100644 index 00000000000..c8653513f1f --- /dev/null +++ b/snippets/visualbasic/System.Threading.Tasks/Task/Overview/startnew1.vb @@ -0,0 +1,22 @@ +' Visual Basic .NET Document +Option Strict On + +' +Imports System.Threading.Tasks + +Module Example3 + Public Sub Main() + Dim t As Task = Task.Factory.StartNew(Sub() + ' Just loop. + Dim ctr As Integer = 0 + For ctr = 0 To 1000000 + Next + Console.WriteLine("Finished {0} loop iterations", + ctr) + End Sub) + t.Wait() + End Sub +End Module +' The example displays the following output: +' Finished 1000001 loop iterations +' diff --git a/snippets/visualbasic/System.Threading.Tasks/TaskScheduler/Overview/Application.xaml b/snippets/visualbasic/System.Threading.Tasks/TaskScheduler/Overview/Application.xaml new file mode 100644 index 00000000000..a51b6ba73e2 --- /dev/null +++ b/snippets/visualbasic/System.Threading.Tasks/TaskScheduler/Overview/Application.xaml @@ -0,0 +1,9 @@ + + + + + diff --git a/snippets/visualbasic/System.Threading.Tasks/TaskScheduler/Overview/Application.xaml.vb b/snippets/visualbasic/System.Threading.Tasks/TaskScheduler/Overview/Application.xaml.vb new file mode 100644 index 00000000000..084cbe917ec --- /dev/null +++ b/snippets/visualbasic/System.Threading.Tasks/TaskScheduler/Overview/Application.xaml.vb @@ -0,0 +1,6 @@ +Class Application + + ' Application-level events, such as Startup, Exit, and DispatcherUnhandledException + ' can be handled in this file. + +End Class diff --git a/snippets/visualbasic/System.Threading.Tasks/TaskScheduler/Overview/AssemblyInfo.vb b/snippets/visualbasic/System.Threading.Tasks/TaskScheduler/Overview/AssemblyInfo.vb new file mode 100644 index 00000000000..025ee7271e7 --- /dev/null +++ b/snippets/visualbasic/System.Threading.Tasks/TaskScheduler/Overview/AssemblyInfo.vb @@ -0,0 +1,11 @@ +Imports System.Windows + +'The ThemeInfo attribute describes where any theme specific and generic resource dictionaries can be found. +'1st parameter: where theme specific resource dictionaries are located +'(used if a resource is not found in the page, +' or application resource dictionaries) + +'2nd parameter: where the generic resource dictionary is located +'(used if a resource is not found in the page, +'app, and any theme specific resource dictionaries) + diff --git a/snippets/visualbasic/System.Threading.Tasks/TaskScheduler/Overview/MainWindow.xaml b/snippets/visualbasic/System.Threading.Tasks/TaskScheduler/Overview/MainWindow.xaml new file mode 100644 index 00000000000..e9509dc18f4 --- /dev/null +++ b/snippets/visualbasic/System.Threading.Tasks/TaskScheduler/Overview/MainWindow.xaml @@ -0,0 +1,14 @@ + + + +