From 6d4aa3d19eb23a9ef14a818810d57d8205990387 Mon Sep 17 00:00:00 2001 From: Genevieve Warren <24882762+gewarren@users.noreply.github.com> Date: Fri, 31 Jul 2026 09:00:25 -0700 Subject: [PATCH 1/3] remove references to .net framework --- .../CPP/marshalas.sizeparamindex.cpp | 2 +- .../DesignerTransaction Sample/CPP/source.cpp | 10 +- .../CPP/instancedescriptor.cpp | 21 +- .../CodeDomProvider/CreateProvider/source.cs | 4 +- .../DesignerTransaction/Overview/source.cs | 90 +- .../Overview/instancedescriptor.cs | 14 +- .../Overview/Project.csproj | 10 + .../Overview/datareceivedevent.cs | 18 +- .../Overview/net_async.cs | 114 +- .../Overview/nmake_async.cs | 137 +- .../Overview/sort_async.cs | 47 +- .../createspecificculture.cs | 4 +- .../createspecificculture2.cs | 8 +- .../PersianCalendar/Overview/Program.cs | 1 + .../PersianCalendar/Overview/Project.csproj | 2 +- .../PersianCalendar/Overview/calendar2.cs | 50 +- .../PersianCalendar/Overview/pcal.cs | 172 +-- .../System.Globalization/TextInfo/Clone/ro.cs | 6 +- .../DllImportAttribute/PreserveSig/example.cs | 14 +- .../marshalas.sizeparamindex.cs | 4 +- .../StructLayoutAttribute/Pack/packex5.cs | 10 - .../StructLayoutAttribute/Pack/packex7.cs | 10 - .../FrameworkName/op_Equality/Operators1.cs | 100 +- .../FrameworkName/op_Equality/Project.csproj | 2 +- .../Overview/simpleservice.cs | 3 +- .../EncodingInfo/Overview/encodinginfo.cs | 163 +-- .../System.Text/StringBuilder/Capacity/cap.cs | 2 +- .../SpinWait/Overview/spinwait.cs | 4 +- .../ThreadStart/Overview/source.cs | 41 +- .../Application/Overview/CSharp.csproj | 110 +- .../Overview/Properties/AssemblyInfo.cs | 12 +- .../System/Console/Overview/example3.cs | 4 +- .../ToBoolean/system.convert snippet.cs | 54 +- .../csharp/System/Single/Overview/Program.cs | 1 + .../System/Single/Overview/Project.csproj | 1 - .../System/Single/Overview/comparison2.cs | 5 +- .../System/Single/Overview/precisionlist3.cs | 5 +- .../System/Single/Overview/precisionlist4a.cs | 35 - .../System/String/IndexOf/ignorable21.cs | 10 +- .../System/TimeSpan/Parse/parsefailure1.cs | 31 - .../System/Type/Assembly/type_assembly.cs | 19 +- .../Overview/net_async.fs | 3 - .../Overview/nmake_async.fs | 3 - .../Overview/sort_async.fs | 3 - .../System.Text/StringBuilder/Capacity/cap.fs | 10 +- .../System/Console/Overview/example3.fs | 1 - .../System/Double/Overview/precision1.fs | 10 +- .../System/String/IndexOf/ignorable21.fs | 5 +- .../System/TimeSpan/Parse/parsefailure1.fs | 9 +- .../System/Type/Assembly/type_assembly.fs | 11 +- .../ServerComputer/FileSystem/Class1.vb | 1102 ----------------- .../CodeDomProvider/CreateProvider/source.vb | 110 +- .../Overview/instancedescriptor.vb | 18 +- .../Overview/net_async.vb | 82 +- .../Overview/nmake_async.vb | 97 +- .../Overview/sort_async.vb | 10 +- .../createspecificculture2.vb | 12 +- .../PersianCalendar/Overview/calendar2.vb | 102 +- .../System.Globalization/TextInfo/Clone/ro.vb | 36 +- .../DllImportAttribute/PreserveSig/example.vb | 24 +- .../marshalas.sizeparamindex.vb | 6 +- .../FrameworkName/op_Equality/Operators1.vb | 68 +- .../Overview/simpleservice.vb | 11 +- .../EncodingInfo/Overview/encodinginfo.vb | 171 +-- .../System.Text/StringBuilder/Capacity/cap.vb | 24 +- .../SpinWait/Overview/spinwait.vb | 4 +- .../System/Console/Overview/example3.vb | 45 +- .../ToBoolean/system.convert snippet.vb | 12 +- .../System/Single/Overview/PrecisionList4a.vb | 37 - .../System/Single/Overview/comparison2.vb | 5 +- .../System/Single/Overview/precisionlist3.vb | 6 +- .../System/String/IndexOf/ignorable21.vb | 9 +- .../System/TimeSpan/Parse/parsefailure1.vb | 7 +- .../System/Type/Assembly/type_assembly.vb | 9 +- .../FrameworkName.xml | 5 +- xml/System.Windows/Application.xml | 16 +- xml/System/String.xml | 3 +- xml/System/Type.xml | 20 +- 78 files changed, 878 insertions(+), 2578 deletions(-) create mode 100644 snippets/csharp/System.Diagnostics/DataReceivedEventArgs/Overview/Project.csproj create mode 100644 snippets/csharp/System.Globalization/PersianCalendar/Overview/Program.cs create mode 100644 snippets/csharp/System/Single/Overview/Program.cs delete mode 100644 snippets/csharp/System/Single/Overview/precisionlist4a.cs delete mode 100644 snippets/csharp/System/TimeSpan/Parse/parsefailure1.cs delete mode 100644 snippets/visualbasic/Microsoft.VisualBasic.Devices/ServerComputer/FileSystem/Class1.vb delete mode 100644 snippets/visualbasic/System/Single/Overview/PrecisionList4a.vb diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Runtime.InteropServices.MarshalAsAttribute.SizeParamIndex/CPP/marshalas.sizeparamindex.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Runtime.InteropServices.MarshalAsAttribute.SizeParamIndex/CPP/marshalas.sizeparamindex.cpp index ba7d39004e3..0af19ff9e7e 100644 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Runtime.InteropServices.MarshalAsAttribute.SizeParamIndex/CPP/marshalas.sizeparamindex.cpp +++ b/snippets/cpp/VS_Snippets_CLR_System/system.Runtime.InteropServices.MarshalAsAttribute.SizeParamIndex/CPP/marshalas.sizeparamindex.cpp @@ -4,7 +4,7 @@ using namespace System; using namespace System::Runtime::InteropServices; // Force the layout of your fields to the C-style struct layout. -// Without this, the .NET Framework will reorder your fields. +// Without this, .NET will reorder your fields. [StructLayoutAttribute(LayoutKind::Sequential)] value struct Vertex diff --git a/snippets/cpp/VS_Snippets_Winforms/DesignerTransaction Sample/CPP/source.cpp b/snippets/cpp/VS_Snippets_Winforms/DesignerTransaction Sample/CPP/source.cpp index 5a435721cde..2cda004f223 100644 --- a/snippets/cpp/VS_Snippets_Winforms/DesignerTransaction Sample/CPP/source.cpp +++ b/snippets/cpp/VS_Snippets_Winforms/DesignerTransaction Sample/CPP/source.cpp @@ -87,14 +87,14 @@ private ref class DTDesigner: public ComponentDesigner { IDesignerHost^ host = static_cast(GetService( IDesignerHost::typeid )); DesignerTransaction^ t = host->CreateTransaction( "Change Text and Size" ); - + /* The code within the using statement is considered to be a single transaction. When the user selects Undo, the system will undo everything executed in this code block. */ if ( notification_mode ) MessageBox::Show( "Entering a Designer-Initiated Designer Transaction" ); - // The .NET Framework automatically associates the TypeDescriptor with the correct component + // .NET automatically associates the TypeDescriptor with the correct component. PropertyDescriptor^ someText = TypeDescriptor::GetProperties( Component )[ "StringProperty" ]; someText->SetValue( Component, "This text was set by the designer for this component." ); PropertyDescriptor^ anInteger = TypeDescriptor::GetProperties( Component )[ "CountProperty" ]; @@ -108,7 +108,7 @@ private ref class DTDesigner: public ComponentDesigner } public: - property DesignerVerbCollection^ Verbs + property DesignerVerbCollection^ Verbs { // The Verbs property is overridden from ComponentDesigner virtual DesignerVerbCollection^ get() override @@ -167,7 +167,7 @@ public ref class DTComponent: public System::ComponentModel::Component } public: - property String^ StringProperty + property String^ StringProperty { String^ get() { @@ -180,7 +180,7 @@ public ref class DTComponent: public System::ComponentModel::Component } } - property int CountProperty + property int CountProperty { int get() { diff --git a/snippets/cpp/VS_Snippets_Winforms/InstanceDescriptorSample/CPP/instancedescriptor.cpp b/snippets/cpp/VS_Snippets_Winforms/InstanceDescriptorSample/CPP/instancedescriptor.cpp index af165ac8484..ca37279d7eb 100644 --- a/snippets/cpp/VS_Snippets_Winforms/InstanceDescriptorSample/CPP/instancedescriptor.cpp +++ b/snippets/cpp/VS_Snippets_Winforms/InstanceDescriptorSample/CPP/instancedescriptor.cpp @@ -12,11 +12,11 @@ using namespace System::Globalization; using namespace System::Collections; using namespace System::Reflection; -/* This sample shows how to support code generation for a custom type of object +/* This sample shows how to support code generation for a custom type of object using a type converter and InstanceDescriptor objects. To use this code, copy it to a file and add the file to a project. Then add - a component to the project and declare a Triangle field and a public property + a component to the project and declare a Triangle field and a public property with accessors for the Triangle field on the component. The Triangle property will be persisted using code generation. @@ -35,7 +35,7 @@ public ref class Triangle public: - property Point Point1 + property Point Point1 { Point get() { @@ -48,7 +48,7 @@ public ref class Triangle } } - property Point Point2 + property Point Point2 { Point get() { @@ -61,7 +61,7 @@ public ref class Triangle } } - property Point Point3 + property Point Point3 { Point get() { @@ -81,12 +81,11 @@ public ref class Triangle P3 = point3; } - - /* A TypeConverter for the Triangle object. Note that you can make it internal, + /* A TypeConverter for the Triangle object. Note that you can make it internal, private, or any scope you want and the designers will still be able to use it through the TypeDescriptor object. This type converter provides the - capability to convert to an InstanceDescriptor. This object can be used by - the .NET Framework to generate source code that creates an instance of a + capability to convert to an InstanceDescriptor. This object can be used by + .NET to generate source code that creates an instance of a Triangle object. */ [System::Security::Permissions::PermissionSet(System::Security:: Permissions::SecurityAction::Demand, Name = "FullTrust")] @@ -104,7 +103,7 @@ public ref class Triangle return true; } - + // Always call the base to see if it can perform the conversion. return TypeConverter::CanConvertTo( context, destinationType ); } @@ -138,7 +137,7 @@ public ref class TestComponent: public System::ComponentModel::Component myTriangle = gcnew Triangle( Point(5,5),Point(10,10),Point(1,8) ); } - property Triangle^ MyTriangle + property Triangle^ MyTriangle { Triangle^ get() { diff --git a/snippets/csharp/System.CodeDom.Compiler/CodeDomProvider/CreateProvider/source.cs b/snippets/csharp/System.CodeDom.Compiler/CodeDomProvider/CreateProvider/source.cs index 43c1530bbe0..3d4b2675da5 100644 --- a/snippets/csharp/System.CodeDom.Compiler/CodeDomProvider/CreateProvider/source.cs +++ b/snippets/csharp/System.CodeDom.Compiler/CodeDomProvider/CreateProvider/source.cs @@ -1,7 +1,5 @@ // System.CodeDom.Compiler.CompilerInfo // -// Requires .NET Framework version 2.0 or higher. -// // The following example displays compiler configuration settings. // Command-line arguments are used to specify a compiler language, // file extension, or provider type. For the given input, the @@ -335,4 +333,4 @@ static void DisplayAllCompilerInfo() } } } -// \ No newline at end of file +// diff --git a/snippets/csharp/System.ComponentModel.Design/DesignerTransaction/Overview/source.cs b/snippets/csharp/System.ComponentModel.Design/DesignerTransaction/Overview/source.cs index ffc0b324b15..ce38fb0f222 100644 --- a/snippets/csharp/System.ComponentModel.Design/DesignerTransaction/Overview/source.cs +++ b/snippets/csharp/System.ComponentModel.Design/DesignerTransaction/Overview/source.cs @@ -6,33 +6,33 @@ using System.Windows.Forms.Design; /* - This sample demonstrates how to perform a series of actions in a designer - transaction, how to change values of properties of a component from a - designer, and how to complete transactions without being interrupted + This sample demonstrates how to perform a series of actions in a designer + transaction, how to change values of properties of a component from a + designer, and how to complete transactions without being interrupted by other activities. - To run this sample, add this code to a class library project and compile. - Create a new Windows Forms project or load a form in the designer. Add a + To run this sample, add this code to a class library project and compile. + Create a new Windows Forms project or load a form in the designer. Add a reference to the class library that was compiled in the first step. - Right-click the Toolbox in design mode and click Customize Toolbox. - Browse to the class library that was compiled in the first step and - select OK until the DTComponent item appears in the Toolbox. Add an - instance of this component to the form. - + Right-click the Toolbox in design mode and click Customize Toolbox. + Browse to the class library that was compiled in the first step and + select OK until the DTComponent item appears in the Toolbox. Add an + instance of this component to the form. + When the component is created and added to the component tray for your - design project, the Initialize method of the designer is called. + design project, the Initialize method of the designer is called. This method displays a message box informing you that designer transaction - event handlers will be registered unless you click Cancel. When you set - properties in the properties window, each change will be encapsulated in - a designer transaction, allowing the change to be undone later. - - When you right-click the component, the shortcut menu for the component - is displayed. The designer constructs this menu according to whether + event handlers will be registered unless you click Cancel. When you set + properties in the properties window, each change will be encapsulated in + a designer transaction, allowing the change to be undone later. + + When you right-click the component, the shortcut menu for the component + is displayed. The designer constructs this menu according to whether designer transaction notifications are enabled, and offers the option - of enabling or disabling the notifications, depending on the current - mode. The shortcut menu also presents a Perform Example Transaction - item, which will set the values of the component's StringProperty and - CountProperty properties. You can undo the last designer transaction using + of enabling or disabling the notifications, depending on the current + mode. The shortcut menu also presents a Perform Example Transaction + item, which will set the values of the component's StringProperty and + CountProperty properties. You can undo the last designer transaction using the Undo command provided by the Visual Studio development environment. */ @@ -44,7 +44,7 @@ public class DTComponent : System.ComponentModel.Component { private string m_String; private int m_Count; - + [DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)] public string StringProperty { @@ -53,7 +53,7 @@ public string StringProperty set { m_String = value; } } - + [DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)] public int CountProperty { @@ -69,18 +69,18 @@ private void InitializeComponent() m_Count = 0; } } - + internal class DTDesigner : ComponentDesigner { private bool notification_mode = false; private int count = 10; - + // The Verbs property is overridden from ComponentDesigner public override DesignerVerbCollection Verbs { get - { - DesignerVerbCollection dvc = new DesignerVerbCollection(); + { + DesignerVerbCollection dvc = new DesignerVerbCollection(); dvc.Add( new DesignerVerb("Perform Example Transaction", new EventHandler(this.DoTransaction)) ); if(notification_mode) dvc.Add(new DesignerVerb("End Designer Transaction Notifications", new EventHandler(this.UnlinkDTNotifications))); @@ -88,12 +88,12 @@ public override DesignerVerbCollection Verbs dvc.Add(new DesignerVerb("Show Designer Transaction Notifications", new EventHandler(this.LinkDTNotifications))); return dvc; } } - + public override void Initialize(System.ComponentModel.IComponent component) { base.Initialize(component); - IDesignerHost host = (IDesignerHost)GetService(typeof(IDesignerHost)); + IDesignerHost host = (IDesignerHost)GetService(typeof(IDesignerHost)); if(host == null) { MessageBox.Show("The IDesignerHost service interface could not be obtained."); @@ -101,18 +101,18 @@ public override void Initialize(System.ComponentModel.IComponent component) } if( MessageBox.Show("Press the Yes button to display notification message boxes for the designer transaction opened and closed notifications.","Link DesignerTransaction Notifications?", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1, MessageBoxOptions.RightAlign) == DialogResult.Yes ) - { + { host.TransactionOpened += new EventHandler(OnDesignerTransactionOpened); host.TransactionClosed += new DesignerTransactionCloseEventHandler(OnDesignerTransactionClosed); notification_mode = true; } } - + private void LinkDTNotifications(object sender, EventArgs e) { if(!notification_mode) { - IDesignerHost host = (IDesignerHost)GetService(typeof(IDesignerHost)); + IDesignerHost host = (IDesignerHost)GetService(typeof(IDesignerHost)); if(host != null) { notification_mode = true; @@ -126,9 +126,9 @@ private void UnlinkDTNotifications(object sender, EventArgs e) { if(notification_mode) { - IDesignerHost host = (IDesignerHost)GetService(typeof(IDesignerHost)); + IDesignerHost host = (IDesignerHost)GetService(typeof(IDesignerHost)); if(host != null) - { + { notification_mode = false; host.TransactionOpened -= new EventHandler(OnDesignerTransactionOpened); host.TransactionClosed -= new DesignerTransactionCloseEventHandler(OnDesignerTransactionClosed); @@ -137,18 +137,18 @@ private void UnlinkDTNotifications(object sender, EventArgs e) } private void OnDesignerTransactionOpened(object sender, EventArgs e) - { + { System.Windows.Forms.MessageBox.Show("A Designer Transaction was started. (TransactionOpened)"); } private void OnDesignerTransactionClosed(object sender, DesignerTransactionCloseEventArgs e) - { + { System.Windows.Forms.MessageBox.Show("A Designer Transaction was completed. (TransactionClosed)"); - } + } - private void DoTransaction(object sender, EventArgs e) - { - IDesignerHost host = (IDesignerHost)GetService(typeof(IDesignerHost)); + private void DoTransaction(object sender, EventArgs e) + { + IDesignerHost host = (IDesignerHost)GetService(typeof(IDesignerHost)); DesignerTransaction t = host.CreateTransaction("Change Text and Size"); /* The code within the using statement is considered to be a single transaction. @@ -157,8 +157,8 @@ private void DoTransaction(object sender, EventArgs e) { if(notification_mode) System.Windows.Forms.MessageBox.Show("Entering a Designer-Initiated Designer Transaction"); - - // The .NET Framework automatically associates the TypeDescriptor with the correct component + + // .NET automatically associates the TypeDescriptor with the correct component. PropertyDescriptor someText = TypeDescriptor.GetProperties(Component)["StringProperty"]; someText.SetValue(Component, "This text was set by the designer for this component."); @@ -168,12 +168,12 @@ private void DoTransaction(object sender, EventArgs e) // Complete the designer transaction. t.Commit(); - + if(notification_mode) System.Windows.Forms.MessageBox.Show("Designer-Initiated Designer Transaction Completed"); } } - + protected override void Dispose(bool disposing) { UnlinkDTNotifications(this, new EventArgs()); @@ -181,4 +181,4 @@ protected override void Dispose(bool disposing) } } } -// \ No newline at end of file +// diff --git a/snippets/csharp/System.ComponentModel/ITypeDescriptorContext/Overview/instancedescriptor.cs b/snippets/csharp/System.ComponentModel/ITypeDescriptorContext/Overview/instancedescriptor.cs index d997f1a0b9d..a66dfed63c1 100644 --- a/snippets/csharp/System.ComponentModel/ITypeDescriptorContext/Overview/instancedescriptor.cs +++ b/snippets/csharp/System.ComponentModel/ITypeDescriptorContext/Overview/instancedescriptor.cs @@ -8,11 +8,11 @@ using System.Reflection; namespace Microsoft.Samples.InstanceDescriptorSample; -// This sample shows how to support code generation for a custom type +// This sample shows how to support code generation for a custom type // of object using a type converter and InstanceDescriptor objects. -// To use this code, copy it to a file and add the file to a project. -// Then add a component to the project and declare a Triangle field and +// To use this code, copy it to a file and add the file to a project. +// Then add a component to the project and declare a Triangle field and // a public property with accessors for the Triangle field on the component. // The Triangle property will be persisted using code generation. @@ -45,11 +45,11 @@ public Triangle(Point point1, Point point2, Point point3) P3 = point3; } - // A TypeConverter for the Triangle object. Note that you can make it internal, + // A TypeConverter for the Triangle object. Note that you can make it internal, // private, or any scope you want and the designers will still be able to use - // it through the TypeDescriptor object. This type converter provides the - // capability to convert to an InstanceDescriptor. This object can be used by - // the .NET Framework to generate source code that creates an instance of a + // it through the TypeDescriptor object.This type converter provides the + // capability to convert to an InstanceDescriptor.This object can be used by + // .NET to generate source code that creates an instance of a // Triangle object. internal class TriangleConverter : TypeConverter { diff --git a/snippets/csharp/System.Diagnostics/DataReceivedEventArgs/Overview/Project.csproj b/snippets/csharp/System.Diagnostics/DataReceivedEventArgs/Overview/Project.csproj new file mode 100644 index 00000000000..2810605dfc8 --- /dev/null +++ b/snippets/csharp/System.Diagnostics/DataReceivedEventArgs/Overview/Project.csproj @@ -0,0 +1,10 @@ + + + + library + net10.0 + enable + enable + + + diff --git a/snippets/csharp/System.Diagnostics/DataReceivedEventArgs/Overview/datareceivedevent.cs b/snippets/csharp/System.Diagnostics/DataReceivedEventArgs/Overview/datareceivedevent.cs index 1e45da4c82a..44261250ba5 100644 --- a/snippets/csharp/System.Diagnostics/DataReceivedEventArgs/Overview/datareceivedevent.cs +++ b/snippets/csharp/System.Diagnostics/DataReceivedEventArgs/Overview/datareceivedevent.cs @@ -1,27 +1,25 @@ // -using System; -using System.IO; using System.Diagnostics; using System.Text; class StandardAsyncOutputExample { - private static int lineCount = 0; - private static StringBuilder output = new StringBuilder(); + private static int s_lineCount = 0; + private static readonly StringBuilder s_output = new(); public static void Main() { - Process process = new Process(); + Process process = new(); process.StartInfo.FileName = "ipconfig.exe"; process.StartInfo.UseShellExecute = false; process.StartInfo.RedirectStandardOutput = true; process.OutputDataReceived += new DataReceivedEventHandler((sender, e) => { // Prepend line numbers to each line of the output. - if (!String.IsNullOrEmpty(e.Data)) + if (!string.IsNullOrEmpty(e.Data)) { - lineCount++; - output.Append("\n[" + lineCount + "]: " + e.Data); + s_lineCount++; + s_output.Append("\n[" + s_lineCount + "]: " + e.Data); } }); @@ -33,7 +31,7 @@ public static void Main() process.WaitForExit(); // Write the redirected output to this application's window. - Console.WriteLine(output); + Console.WriteLine(s_output); process.WaitForExit(); process.Close(); @@ -42,4 +40,4 @@ public static void Main() Console.ReadLine(); } } -// \ No newline at end of file +// diff --git a/snippets/csharp/System.Diagnostics/DataReceivedEventArgs/Overview/net_async.cs b/snippets/csharp/System.Diagnostics/DataReceivedEventArgs/Overview/net_async.cs index 48777aef8f5..feb1727e783 100644 --- a/snippets/csharp/System.Diagnostics/DataReceivedEventArgs/Overview/net_async.cs +++ b/snippets/csharp/System.Diagnostics/DataReceivedEventArgs/Overview/net_async.cs @@ -1,56 +1,46 @@ -// System.Diagnostics -// -// Requires .NET Framework version 1.2 or higher. - -// The following example uses the net view command to list the +// The following example uses the net view command to list the // available network resources available on a remote computer, // and displays the results to the console. Specifying the optional // error log file redirects error output to that file. // -// Define the namespaces used by this sample. -using System; -using System.Text; -using System.Globalization; -using System.IO; using System.Diagnostics; -using System.Threading; -using System.ComponentModel; +using System.Globalization; +using System.Text; namespace ProcessAsyncStreamSamples { - class ProcessNetStreamRedirection { // Define static variables shared by class methods. - private static StreamWriter streamError =null; - private static String netErrorFile = ""; - private static StringBuilder netOutput = null; - private static bool errorRedirect = false; - private static bool errorsWritten = false; + private static StreamWriter? s_streamError; + private static string? s_netErrorFile = ""; + private static StringBuilder? s_netOutput; + private static bool s_errorRedirect = false; + private static bool s_errorsWritten = false; public static void RedirectNetCommandStreams() { - String netArguments; + string? netArguments; Process netProcess; // Get the input computer name. Console.WriteLine("Enter the computer name for the net view command:"); - netArguments = Console.ReadLine().ToUpper(CultureInfo.InvariantCulture); - if (String.IsNullOrEmpty(netArguments)) + netArguments = Console.ReadLine()?.ToUpper(CultureInfo.InvariantCulture); + if (string.IsNullOrEmpty(netArguments)) { // Default to the help command if there is not an input argument. netArguments = "/?"; } // Check if errors should be redirected to a file. - errorsWritten = false; + s_errorsWritten = false; Console.WriteLine("Enter a fully qualified path to an error log file"); Console.WriteLine(" or just press Enter to write errors to console:"); - netErrorFile = Console.ReadLine().ToUpper(CultureInfo.InvariantCulture); - if (!String.IsNullOrEmpty(netErrorFile)) + s_netErrorFile = Console.ReadLine()?.ToUpper(CultureInfo.InvariantCulture); + if (!string.IsNullOrEmpty(s_netErrorFile)) { - errorRedirect = true; + s_errorRedirect = true; } // Note that at this point, netArguments and netErrorFile @@ -62,8 +52,7 @@ public static void RedirectNetCommandStreams() netProcess.StartInfo.FileName = "Net.exe"; // Build the net command argument list. - netProcess.StartInfo.Arguments = String.Format("view {0}", - netArguments); + netProcess.StartInfo.Arguments = $"view {netArguments}"; // Set UseShellExecute to false for redirection. netProcess.StartInfo.UseShellExecute = false; @@ -72,9 +61,9 @@ public static void RedirectNetCommandStreams() // This stream is read asynchronously using an event handler. netProcess.StartInfo.RedirectStandardOutput = true; netProcess.OutputDataReceived += new DataReceivedEventHandler(NetOutputDataHandler); - netOutput = new StringBuilder(); + s_netOutput = new StringBuilder(); - if (errorRedirect) + if (s_errorRedirect) { // Redirect the error output of the net command. netProcess.StartInfo.RedirectStandardError = true; @@ -86,12 +75,10 @@ public static void RedirectNetCommandStreams() netProcess.StartInfo.RedirectStandardError = false; } - Console.WriteLine("\nStarting process: net {0}", - netProcess.StartInfo.Arguments); - if (errorRedirect) + Console.WriteLine($"\nStarting process: net {netProcess.StartInfo.Arguments}"); + if (s_errorRedirect) { - Console.WriteLine("Errors will be written to the file {0}", - netErrorFile); + Console.WriteLine($"Errors will be written to the file {s_netErrorFile}"); } // Start the process. @@ -100,7 +87,7 @@ public static void RedirectNetCommandStreams() // Start the asynchronous read of the standard output stream. netProcess.BeginOutputReadLine(); - if (errorRedirect) + if (s_errorRedirect) { // Start the asynchronous read of the standard // error stream. @@ -110,39 +97,37 @@ public static void RedirectNetCommandStreams() // Let the net command run, collecting the output. netProcess.WaitForExit(); - if (streamError != null) + if (s_streamError != null) { // Close the error file. - streamError.Close(); + s_streamError.Close(); } else { // Set errorsWritten to false if the stream is not // open. Either there are no errors, or the error // file could not be opened. - errorsWritten = false; + s_errorsWritten = false; } - if (netOutput.Length > 0) + if (s_netOutput.Length > 0) { // If the process wrote more than just // white space, write the output to the console. - Console.WriteLine("\nPublic network shares from net view:\n{0}\n", - netOutput); + Console.WriteLine($"\nPublic network shares from net view:\n{s_netOutput}\n"); } - if (errorsWritten) + if (s_errorsWritten) { // Signal that the error file had something // written to it. - String [] errorOutput = File.ReadAllLines(netErrorFile); + string[] errorOutput = File.ReadAllLines(s_netErrorFile); if (errorOutput.Length > 0) { - Console.WriteLine("\nThe following error output was appended to {0}.", - netErrorFile); - foreach (String errLine in errorOutput) + Console.WriteLine($"\nThe following error output was appended to {s_netErrorFile}:"); + foreach (string errLine in errorOutput) { - Console.WriteLine(" {0}", errLine); + Console.WriteLine($" {errLine}"); } } Console.WriteLine(); @@ -155,10 +140,10 @@ private static void NetOutputDataHandler(object sendingProcess, DataReceivedEventArgs outLine) { // Collect the net view command output. - if (!String.IsNullOrEmpty(outLine.Data)) + if (!string.IsNullOrEmpty(outLine.Data)) { // Add the text to the collected output. - netOutput.Append(Environment.NewLine + " " + outLine.Data); + s_netOutput.Append(Environment.NewLine + " " + outLine.Data); } } @@ -168,16 +153,16 @@ private static void NetErrorDataHandler(object sendingProcess, // Write the error text to the file if there is something // to write and an error file has been specified. - if (!String.IsNullOrEmpty(errLine.Data)) + if (!string.IsNullOrEmpty(errLine.Data)) { - if (!errorsWritten) + if (!s_errorsWritten) { - if (streamError == null) + if (s_streamError == null) { // Open the file. try { - streamError = new StreamWriter(netErrorFile, true); + s_streamError = new StreamWriter(s_netErrorFile, true); } catch (Exception e) { @@ -186,22 +171,22 @@ private static void NetErrorDataHandler(object sendingProcess, } } - if (streamError != null) + if (s_streamError != null) { // Write a header to the file if this is the first // call to the error output handler. - streamError.WriteLine(); - streamError.WriteLine(DateTime.Now.ToString()); - streamError.WriteLine("Net View error output:"); + s_streamError.WriteLine(); + s_streamError.WriteLine(DateTime.Now.ToString()); + s_streamError.WriteLine("Net View error output:"); } - errorsWritten = true; + s_errorsWritten = true; } - if (streamError != null) + if (s_streamError != null) { // Write redirected errors to the file. - streamError.WriteLine(errLine.Data); - streamError.Flush(); + s_streamError.WriteLine(errLine.Data); + s_streamError.Flush(); } } } @@ -211,11 +196,10 @@ private static void NetErrorDataHandler(object sendingProcess, namespace ProcessAsyncStreamSamples { - - class ProcessSampleMain + class ProcessAsyncSample { /// The main entry point for the application. - static void Main() + static void Run() { try { @@ -228,4 +212,4 @@ static void Main() } } } -} \ No newline at end of file +} diff --git a/snippets/csharp/System.Diagnostics/DataReceivedEventArgs/Overview/nmake_async.cs b/snippets/csharp/System.Diagnostics/DataReceivedEventArgs/Overview/nmake_async.cs index c22103385f4..a06b5e7e0a8 100644 --- a/snippets/csharp/System.Diagnostics/DataReceivedEventArgs/Overview/nmake_async.cs +++ b/snippets/csharp/System.Diagnostics/DataReceivedEventArgs/Overview/nmake_async.cs @@ -1,14 +1,5 @@ -// System.Diagnostics -// -// Requires .NET Framework version 1.2 or higher. - -// Define the namespaces used by this sample. -using System; +using System.Diagnostics; using System.Text; -using System.IO; -using System.Diagnostics; -using System.Threading; -using System.ComponentModel; // namespace ProcessAsyncStreamSamples @@ -16,43 +7,41 @@ namespace ProcessAsyncStreamSamples class ProcessNMakeStreamRedirection { // Define static variables shared by class methods. - private static StreamWriter buildLogStream =null; - private static Mutex logMutex = new Mutex(); - private static int maxLogLines = 25; - private static int currentLogLines = 0; + private static StreamWriter? s_buildLogStream; + private static readonly Mutex s_logMutex = new(); + private static int s_maxLogLines = 25; + private static int s_currentLogLines = 0; public static void RedirectNMakeCommandStreams() { - String nmakeArguments = null; + string? nmakeArguments = null; Process nmakeProcess; // Get the input nmake command-line arguments. - Console.WriteLine("Enter the NMake command line arguments " + - "(@commandfile or /f makefile, etc):"); - String inputText = Console.ReadLine(); - if (!String.IsNullOrEmpty(inputText)) + while (string.IsNullOrEmpty(nmakeArguments)) { - nmakeArguments = inputText; + Console.WriteLine("Enter the NMake command line arguments " + + "(@commandfile or /f makefile, etc):"); + nmakeArguments = Console.ReadLine(); } Console.WriteLine("Enter max line limit for log file (default is 25):"); - inputText = Console.ReadLine(); - if (!String.IsNullOrEmpty(inputText)) + string? inputText = Console.ReadLine(); + if (!string.IsNullOrEmpty(inputText)) { - if (!Int32.TryParse(inputText, out maxLogLines)) + if (!int.TryParse(inputText, out s_maxLogLines)) { - maxLogLines = 25; + s_maxLogLines = 25; } } - Console.WriteLine("Output beyond {0} lines will be ignored.", - maxLogLines); + Console.WriteLine($"Output beyond {s_maxLogLines} lines will be ignored."); // Initialize the process and its StartInfo properties. nmakeProcess = new Process(); nmakeProcess.StartInfo.FileName = "NMake.exe"; // Build the nmake command argument list. - if (!String.IsNullOrEmpty(nmakeArguments)) + if (!string.IsNullOrEmpty(nmakeArguments)) { nmakeProcess.StartInfo.Arguments = nmakeArguments; } @@ -69,45 +58,44 @@ public static void RedirectNMakeCommandStreams() nmakeProcess.StartInfo.RedirectStandardError = true; nmakeProcess.ErrorDataReceived += new DataReceivedEventHandler(NMakeErrorDataHandler); - logMutex.WaitOne(); + s_logMutex.WaitOne(); - currentLogLines = 0; + s_currentLogLines = 0; // Write a header to the log file. - const String buildLogFile = "NmakeCmd.Txt"; + const string buildLogFile = "NmakeCmd.Txt"; try { - buildLogStream = new StreamWriter(buildLogFile, true); + s_buildLogStream = new StreamWriter(buildLogFile, true); } catch (Exception e) { - Console.WriteLine("Could not open output file {0}", buildLogFile); - Console.WriteLine("Exception = {0}", e.ToString()); + Console.WriteLine($"Could not open output file {buildLogFile}"); + Console.WriteLine($"Exception = {e}"); Console.WriteLine(e.Message); - buildLogStream = null; + s_buildLogStream = null; } - if (buildLogStream != null) + if (s_buildLogStream != null) { - Console.WriteLine("Nmake output logged to {0}", - buildLogFile); + Console.WriteLine($"Nmake output logged to {buildLogFile}"); - buildLogStream.WriteLine(); - buildLogStream.WriteLine(DateTime.Now.ToString()); - if (!String.IsNullOrEmpty(nmakeArguments)) + s_buildLogStream.WriteLine(); + s_buildLogStream.WriteLine(DateTime.Now.ToString()); + if (!string.IsNullOrEmpty(nmakeArguments)) { - buildLogStream.Write("Command line = NMake {0}", + s_buildLogStream.Write("Command line = NMake {0}", nmakeArguments); } else { - buildLogStream.Write("Command line = Nmake"); + s_buildLogStream.Write("Command line = Nmake"); } - buildLogStream.WriteLine(); - buildLogStream.Flush(); + s_buildLogStream.WriteLine(); + s_buildLogStream.Flush(); - logMutex.ReleaseMutex(); + s_logMutex.ReleaseMutex(); // Start the process. Console.WriteLine(); @@ -125,8 +113,8 @@ public static void RedirectNMakeCommandStreams() nmakeProcess.WaitForExit(); nmakeProcess.Close(); - buildLogStream.Close(); - logMutex.Dispose(); + s_buildLogStream.Close(); + s_logMutex.Dispose(); } } @@ -137,25 +125,24 @@ private static void NMakeOutputDataHandler(object sendingProcess, // logging it to the output file. Cancel the read // operation when the maximum line limit is reached. - if (!String.IsNullOrEmpty(outLine.Data)) + if (!string.IsNullOrEmpty(outLine.Data)) { - logMutex.WaitOne(); + s_logMutex.WaitOne(); - currentLogLines++; - if (currentLogLines > maxLogLines) + s_currentLogLines++; + if (s_currentLogLines > s_maxLogLines) { // Display the line to the console. // Skip writing the line to the log file. - Console.WriteLine("StdOut: {0}", outLine.Data); + Console.WriteLine($"StdOut: {outLine.Data}"); } - else if (currentLogLines == maxLogLines) + else if (s_currentLogLines == s_maxLogLines) { LogToFile("StdOut", "", true); // Stop reading the output streams. - Process p = sendingProcess as Process; - if (p != null) + if (sendingProcess is Process p) { p.CancelOutputRead(); p.CancelErrorRead(); @@ -166,7 +153,7 @@ private static void NMakeOutputDataHandler(object sendingProcess, // Write the line to the log file. LogToFile("StdOut", outLine.Data, true); } - logMutex.ReleaseMutex(); + s_logMutex.ReleaseMutex(); } } @@ -177,25 +164,24 @@ private static void NMakeErrorDataHandler(object sendingProcess, // logging it to the output file. Cancel the error output // read operation when the maximum line limit is reached. - if (!String.IsNullOrEmpty(errLine.Data)) + if (!string.IsNullOrEmpty(errLine.Data)) { - logMutex.WaitOne(); + s_logMutex.WaitOne(); - currentLogLines++; - if (currentLogLines > maxLogLines) + s_currentLogLines++; + if (s_currentLogLines > s_maxLogLines) { // Display the error line to the console. // Skip writing the line to the log file. - Console.WriteLine("StdErr: {0}", errLine.Data); + Console.WriteLine($"StdErr: {errLine.Data}"); } - else if (currentLogLines == maxLogLines) + else if (s_currentLogLines == s_maxLogLines) { LogToFile("StdErr", "", true); // Stop reading the output streams - Process p = sendingProcess as Process; - if (p != null) + if (sendingProcess is Process p) { p.CancelErrorRead(); p.CancelOutputRead(); @@ -207,31 +193,31 @@ private static void NMakeErrorDataHandler(object sendingProcess, LogToFile("StdErr", errLine.Data, true); } - logMutex.ReleaseMutex(); + s_logMutex.ReleaseMutex(); } } - private static void LogToFile(String logPrefix, - String logText, bool echoToConsole) + private static void LogToFile(string logPrefix, + string logText, bool echoToConsole) { // Write the specified line to the log file stream. StringBuilder logString = new StringBuilder(); - if (!String.IsNullOrEmpty(logPrefix)) + if (!string.IsNullOrEmpty(logPrefix)) { logString.AppendFormat("{0}> ", logPrefix); } - if (!String.IsNullOrEmpty(logText)) + if (!string.IsNullOrEmpty(logText)) { logString.Append(logText); } - if (buildLogStream != null) + if (s_buildLogStream != null) { - buildLogStream.WriteLine("[{0}] {1}", + s_buildLogStream.WriteLine("[{0}] {1}", DateTime.Now.ToString(), logString.ToString()); - buildLogStream.Flush(); + s_buildLogStream.Flush(); } if (echoToConsole) @@ -245,11 +231,10 @@ private static void LogToFile(String logPrefix, namespace ProcessAsyncStreamSamples { - - class ProcessSampleMain + class ProcessSample { /// The main entry point for the application. - static void Main() + static void Run() { try { @@ -262,4 +247,4 @@ static void Main() } } } -} \ No newline at end of file +} diff --git a/snippets/csharp/System.Diagnostics/DataReceivedEventArgs/Overview/sort_async.cs b/snippets/csharp/System.Diagnostics/DataReceivedEventArgs/Overview/sort_async.cs index 4dcccfabce5..3ddaea0bef2 100644 --- a/snippets/csharp/System.Diagnostics/DataReceivedEventArgs/Overview/sort_async.cs +++ b/snippets/csharp/System.Diagnostics/DataReceivedEventArgs/Overview/sort_async.cs @@ -1,26 +1,18 @@ -// System.Diagnostics -// -// Requires .NET Framework version 1.2 or higher. - -// The following example uses the sort command to sort a list +// The following example uses the sort command to sort a list // of input text lines, and displays the sorted list to the console. // // Define the namespaces used by this sample. -using System; -using System.Text; -using System.IO; using System.Diagnostics; -using System.Threading; -using System.ComponentModel; +using System.Text; namespace ProcessAsyncStreamSamples { class SortOutputRedirection { // Define static variables shared by class methods. - private static StringBuilder sortOutput = null; - private static int numOutputLines = 0; + private static StringBuilder? s_sortOutput; + private static int s_numOutputLines = 0; public static void SortInputListText() { @@ -28,7 +20,7 @@ public static void SortInputListText() // The sort command is a console application that // reads and sorts text input. - Process sortProcess = new Process(); + Process sortProcess = new(); sortProcess.StartInfo.FileName = "Sort.exe"; // Set UseShellExecute to false for redirection. @@ -37,7 +29,7 @@ public static void SortInputListText() // Redirect the standard output of the sort command. // This stream is read asynchronously using an event handler. sortProcess.StartInfo.RedirectStandardOutput = true; - sortOutput = new StringBuilder(); + s_sortOutput = new StringBuilder(); // Set our event handler to asynchronously read the sort output. sortProcess.OutputDataReceived += SortOutputHandler; @@ -55,24 +47,24 @@ public static void SortInputListText() // Start the asynchronous read of the sort output stream. sortProcess.BeginOutputReadLine(); - // Prompt the user for input text lines. Write each + // Prompt the user for input text lines. Write each // line to the redirected input stream of the sort command. Console.WriteLine("Ready to sort up to 50 lines of text"); - String inputText; + string? inputText; int numInputLines = 0; do { Console.WriteLine("Enter a text line (or press the Enter key to stop):"); inputText = Console.ReadLine(); - if (!String.IsNullOrEmpty(inputText)) + if (!string.IsNullOrEmpty(inputText)) { numInputLines++; sortStreamWriter.WriteLine(inputText); } } - while (!String.IsNullOrEmpty(inputText) && (numInputLines < 50)); + while (!string.IsNullOrEmpty(inputText) && (numInputLines < 50)); Console.WriteLine(""); Console.WriteLine(); @@ -82,12 +74,12 @@ public static void SortInputListText() // Wait for the sort process to write the sorted text lines. sortProcess.WaitForExit(); - if (numOutputLines > 0) + if (s_numOutputLines > 0) { // Write the formatted and sorted output to the console. - Console.WriteLine($" Sort results = {numOutputLines} sorted text line(s) "); + Console.WriteLine($" Sort results = {s_numOutputLines} sorted text line(s) "); Console.WriteLine("----------"); - Console.WriteLine(sortOutput); + Console.WriteLine(s_sortOutput); } else { @@ -101,13 +93,12 @@ private static void SortOutputHandler(object sendingProcess, DataReceivedEventArgs outLine) { // Collect the sort command output. - if (!String.IsNullOrEmpty(outLine.Data)) + if (!string.IsNullOrEmpty(outLine.Data)) { - numOutputLines++; + s_numOutputLines++; // Add the text to the collected output. - sortOutput.Append(Environment.NewLine + - $"[{numOutputLines}] - {outLine.Data}"); + s_sortOutput.Append($"{Environment.NewLine}[{s_numOutputLines}] - {outLine.Data}"); } } } @@ -115,11 +106,9 @@ private static void SortOutputHandler(object sendingProcess, namespace ProcessAsyncStreamSamples { - - class ProcessSampleMain + class ProcessSortSample { - /// The main entry point for the application. - static void Main() + static void Run() { try { diff --git a/snippets/csharp/System.Globalization/CultureInfo/CreateSpecificCulture/createspecificculture.cs b/snippets/csharp/System.Globalization/CultureInfo/CreateSpecificCulture/createspecificculture.cs index 4721999ba5f..5b64bf6a60a 100644 --- a/snippets/csharp/System.Globalization/CultureInfo/CreateSpecificCulture/createspecificculture.cs +++ b/snippets/csharp/System.Globalization/CultureInfo/CreateSpecificCulture/createspecificculture.cs @@ -6,14 +6,12 @@ public class SamplesCultureInfo { - public static void Main() { - // Prints the header. Console.WriteLine("CULTURE SPECIFIC CULTURE"); - // Determines the specific culture associated with each culture in the .NET Framework. + // Determines the specific culture associated with each culture in .NET. foreach (CultureInfo ci in CultureInfo.GetCultures(CultureTypes.AllCultures)) { Console.Write("{0,-12} {1,-40}", ci.Name, ci.EnglishName); diff --git a/snippets/csharp/System.Globalization/CultureInfo/CreateSpecificCulture/createspecificculture2.cs b/snippets/csharp/System.Globalization/CultureInfo/CreateSpecificCulture/createspecificculture2.cs index 88cda77e489..7a310638a58 100644 --- a/snippets/csharp/System.Globalization/CultureInfo/CreateSpecificCulture/createspecificculture2.cs +++ b/snippets/csharp/System.Globalization/CultureInfo/CreateSpecificCulture/createspecificculture2.cs @@ -11,13 +11,13 @@ public static void Main() // Display the header. Console.WriteLine("{0,-53}{1}", "CULTURE", "SPECIFIC CULTURE"); - // Get each neutral culture in the .NET Framework. + // Get each neutral culture in .NET. CultureInfo[] cultures = CultureInfo.GetCultures(CultureTypes.NeutralCultures); // Sort the returned array by name. Array.Sort(cultures, new NamePropertyComparer()); // Determine the specific culture associated with each neutral culture. - foreach (var culture in cultures) + foreach (CultureInfo culture in cultures) { Console.Write("{0,-12} {1,-40}", culture.Name, culture.EnglishName); try { @@ -45,7 +45,9 @@ public int Compare(T x, T y) return String.Compare((string) pX.GetValue(x, null), (string) pY.GetValue(y, null)); } } -// The example displays the following output on a Windows system. This output has been cropped for brevity. + +// The example displays the following output on a Windows system. This output has been cropped for brevity. +// // CULTURE SPECIFIC CULTURE // Invariant Language (Invariant Country) // aa Afar aa-ET diff --git a/snippets/csharp/System.Globalization/PersianCalendar/Overview/Program.cs b/snippets/csharp/System.Globalization/PersianCalendar/Overview/Program.cs new file mode 100644 index 00000000000..5a31894d3c4 --- /dev/null +++ b/snippets/csharp/System.Globalization/PersianCalendar/Overview/Program.cs @@ -0,0 +1 @@ +Example.Main(); diff --git a/snippets/csharp/System.Globalization/PersianCalendar/Overview/Project.csproj b/snippets/csharp/System.Globalization/PersianCalendar/Overview/Project.csproj index a369cfa8a80..ffb97e9872d 100644 --- a/snippets/csharp/System.Globalization/PersianCalendar/Overview/Project.csproj +++ b/snippets/csharp/System.Globalization/PersianCalendar/Overview/Project.csproj @@ -1,7 +1,7 @@ - Library + Exe net10.0 diff --git a/snippets/csharp/System.Globalization/PersianCalendar/Overview/calendar2.cs b/snippets/csharp/System.Globalization/PersianCalendar/Overview/calendar2.cs index 9e52133b85c..10bdf65b90d 100644 --- a/snippets/csharp/System.Globalization/PersianCalendar/Overview/calendar2.cs +++ b/snippets/csharp/System.Globalization/PersianCalendar/Overview/calendar2.cs @@ -4,9 +4,9 @@ public class Example { - public static void Main() - { - PersianCalendar pc = new PersianCalendar(); + public static void Main() + { + PersianCalendar pc = new(); DateTime thisDate = DateTime.Now; // Display the current date using the Gregorian and Persian calendars. @@ -68,38 +68,24 @@ public static void Main() pc.GetHour(pc.MinSupportedDateTime), pc.GetMinute(pc.MaxSupportedDateTime), pc.GetSecond(pc.MaxSupportedDateTime)); - } + } } -// The example displays the following output when run under the .NET Framework 4.6: -// Today in the Gregorian Calendar: Monday, 2/4/2013 9:11:36 AM -// Today in the Persian Calendar: Monday, 11/16/1391 9:11:36 -// -// Gregorian Calendar: Tuesday, May 28, 2013 -// Persian Calendar: Tuesday, 3/7/1392 10:35:0 -// -// Gregorian Calendar: Tuesday, July 12, 2016 -// Persian Calendar: Tuesday, 4/22/1395 12:30:0 -// -// Minimum Persian Calendar date (Gregorian Calendar): Friday, March 22, 0622 -// Minimum Persian Calendar date (Persian Calendar): Friday, 1/1/1 0:0:0 -// -// Maximum Persian Calendar date (Gregorian Calendar): Friday, December 31, 9999 -// Maximum Persian Calendar date (Persian Calendar): Friday, 10/13/9378 0:59:59 -// -// The example displays the following output when run under versions of -// the .NET Framework before the .NET Framework 4.6: -// Today in the Gregorian Calendar: Monday, 2/4/2013 9:11:36 AM -// Today in the Persian Calendar: Monday, 11/16/1391 9:11:36 + +// The example displays output similar to the following: + +// Today in the Gregorian Calendar: Thursday, 7/30/2026 4:19:25 PM +// Today in the Persian Calendar: Thursday, 5/8/1405 16:19:25 // -// Gregorian Calendar: Tuesday, May 28, 2013 -// Persian Calendar: Tuesday, 3/7/1392 10:35:0 +// Gregorian Calendar: Tuesday, May 28, 2013 +// Persian Calendar: Tuesday, 3/7/1392 10:35:0 // -// Gregorian Calendar: Tuesday, July 12, 2016 -// Persian Calendar: Tuesday, 4/22/1395 12:30:0 +// Gregorian Calendar: Tuesday, July 12, 2016 +// Persian Calendar: Tuesday, 4/22/1395 12:30:0 // -// Minimum Persian Calendar date (Gregorian Calendar): Thursday, March 21, 0622 -// Minimum Persian Calendar date (Persian Calendar): Thursday, 1/1/1 0:0:0 +// Minimum Persian Calendar date (Gregorian Calendar): Friday, March 22, 0622 +// Minimum Persian Calendar date (Persian Calendar): Friday, 1/1/1 0:0:0 // -// Maximum Persian Calendar date (Gregorian Calendar): Friday, December 31, 9999 -// Maximum Persian Calendar date (Persian Calendar): Friday, 10/10/9378 0:59:59 +// Maximum Persian Calendar date (Gregorian Calendar): Friday, December 31, 9999 +// Maximum Persian Calendar date (Persian Calendar): Friday, 10/13/9378 0:59:59 + // diff --git a/snippets/csharp/System.Globalization/PersianCalendar/Overview/pcal.cs b/snippets/csharp/System.Globalization/PersianCalendar/Overview/pcal.cs index 86d696bdd60..c7633db1d4a 100644 --- a/snippets/csharp/System.Globalization/PersianCalendar/Overview/pcal.cs +++ b/snippets/csharp/System.Globalization/PersianCalendar/Overview/pcal.cs @@ -6,62 +6,62 @@ class Sample { public static void Main() { - PersianCalendar jc = new PersianCalendar(); - DateTime thisDate = DateTime.Now; + PersianCalendar jc = new(); + DateTime thisDate = DateTime.Now; - //-------------------------------------------------------------------------------- - // Properties - //-------------------------------------------------------------------------------- - Console.WriteLine("\n........... Selected Properties .....................\n"); - Console.Write("Eras:"); - foreach (int era in jc.Eras) - { - Console.WriteLine(" era = {0}", era); - } - //-------------------------------------------------------------------------------- - Console.WriteLine("\nTwoDigitYearMax = {0}", jc.TwoDigitYearMax); - //-------------------------------------------------------------------------------- - // Methods - //-------------------------------------------------------------------------------- - Console.WriteLine("\n............ Selected Methods .......................\n"); + //-------------------------------------------------------------------------------- + // Properties + //-------------------------------------------------------------------------------- + Console.WriteLine("\n........... Selected Properties .....................\n"); + Console.Write("Eras:"); + foreach (int era in jc.Eras) + { + Console.WriteLine(" era = {0}", era); + } + //-------------------------------------------------------------------------------- + Console.WriteLine("\nTwoDigitYearMax = {0}", jc.TwoDigitYearMax); + //-------------------------------------------------------------------------------- + // Methods + //-------------------------------------------------------------------------------- + Console.WriteLine("\n............ Selected Methods .......................\n"); - //-------------------------------------------------------------------------------- - Console.WriteLine("GetDayOfYear: day = {0}", jc.GetDayOfYear(thisDate)); - //-------------------------------------------------------------------------------- - Console.WriteLine("GetDaysInMonth: days = {0}", - jc.GetDaysInMonth( thisDate.Year, thisDate.Month, - PersianCalendar.PersianEra)); - //-------------------------------------------------------------------------------- - Console.WriteLine("GetDaysInYear: days = {0}", - jc.GetDaysInYear(thisDate.Year, PersianCalendar.PersianEra)); - //-------------------------------------------------------------------------------- - Console.WriteLine("GetLeapMonth: leap month (if any) = {0}", - jc.GetLeapMonth(thisDate.Year, PersianCalendar.PersianEra)); - //------------------------------------------------------------- - Console.WriteLine("GetMonthsInYear: months in a year = {0}", - jc.GetMonthsInYear(thisDate.Year, PersianCalendar.PersianEra)); - //-------------------------------------------------------------------------------- - Console.WriteLine("IsLeapDay: This is a leap day = {0}", - jc.IsLeapDay(thisDate.Year, thisDate.Month, thisDate.Day, - PersianCalendar.PersianEra)); - //-------------------------------------------------------------------------------- - Console.WriteLine("IsLeapMonth: This is a leap month = {0}", - jc.IsLeapMonth(thisDate.Year, thisDate.Month, - PersianCalendar.PersianEra)); - //-------------------------------------------------------------------------------- - Console.WriteLine("IsLeapYear: 1370 is a leap year = {0}", - jc.IsLeapYear(1370, PersianCalendar.PersianEra)); - //-------------------------------------------------------------------------------- + //-------------------------------------------------------------------------------- + Console.WriteLine("GetDayOfYear: day = {0}", jc.GetDayOfYear(thisDate)); + //-------------------------------------------------------------------------------- + Console.WriteLine("GetDaysInMonth: days = {0}", + jc.GetDaysInMonth(thisDate.Year, thisDate.Month, + PersianCalendar.PersianEra)); + //-------------------------------------------------------------------------------- + Console.WriteLine("GetDaysInYear: days = {0}", + jc.GetDaysInYear(thisDate.Year, PersianCalendar.PersianEra)); + //-------------------------------------------------------------------------------- + Console.WriteLine("GetLeapMonth: leap month (if any) = {0}", + jc.GetLeapMonth(thisDate.Year, PersianCalendar.PersianEra)); + //------------------------------------------------------------- + Console.WriteLine("GetMonthsInYear: months in a year = {0}", + jc.GetMonthsInYear(thisDate.Year, PersianCalendar.PersianEra)); + //-------------------------------------------------------------------------------- + Console.WriteLine("IsLeapDay: This is a leap day = {0}", + jc.IsLeapDay(thisDate.Year, thisDate.Month, thisDate.Day, + PersianCalendar.PersianEra)); + //-------------------------------------------------------------------------------- + Console.WriteLine("IsLeapMonth: This is a leap month = {0}", + jc.IsLeapMonth(thisDate.Year, thisDate.Month, + PersianCalendar.PersianEra)); + //-------------------------------------------------------------------------------- + Console.WriteLine("IsLeapYear: 1370 is a leap year = {0}", + jc.IsLeapYear(1370, PersianCalendar.PersianEra)); + //-------------------------------------------------------------------------------- - // Get the 4-digit year for a year whose last two digits are 99. The 4-digit year - // depends on the current value of the TwoDigitYearMax property. + // Get the 4-digit year for a year whose last two digits are 99. The 4-digit year + // depends on the current value of the TwoDigitYearMax property. - Console.WriteLine("ToFourDigitYear:"); - Console.WriteLine(" If TwoDigitYearMax = {0}, ToFourDigitYear(99) = {1}", - jc.TwoDigitYearMax, jc.ToFourDigitYear(99)); - jc.TwoDigitYearMax = thisDate.Year; - Console.WriteLine(" If TwoDigitYearMax = {0}, ToFourDigitYear(99) = {1}", - jc.TwoDigitYearMax, jc.ToFourDigitYear(99)); + Console.WriteLine("ToFourDigitYear:"); + Console.WriteLine(" If TwoDigitYearMax = {0}, ToFourDigitYear(99) = {1}", + jc.TwoDigitYearMax, jc.ToFourDigitYear(99)); + jc.TwoDigitYearMax = thisDate.Year; + Console.WriteLine(" If TwoDigitYearMax = {0}, ToFourDigitYear(99) = {1}", + jc.TwoDigitYearMax, jc.ToFourDigitYear(99)); } } // The example displays the following output: @@ -88,40 +88,40 @@ public static void Main() public class CalendarConversion { - public void ConvertToday() - { - // - // Instantiate a PersianCalendar object - PersianCalendar pc = new PersianCalendar(); + public void ConvertToday() + { + // + // Instantiate a PersianCalendar object + PersianCalendar pc = new PersianCalendar(); - // Define a Gregorian date of 3/21/2007 12:47:15 - DateTime gregorianDate = new DateTime(2007, 3, 21, 00, 47, 15); - Console.WriteLine("The Gregorian calendar date is {0:G}", gregorianDate); - // Convert the Gregorian date to its equivalent date in the Persian calendar - Console.WriteLine("The Persian calendar date is {0}/{1}/{2} {3}:{4}:{5}.", - pc.GetMonth(gregorianDate), - pc.GetDayOfMonth(gregorianDate), - pc.GetYear(gregorianDate), - pc.GetHour(gregorianDate), - pc.GetMinute(gregorianDate), - pc.GetSecond(gregorianDate)); - // Convert the Persian calendar date back to the Gregorian calendar date - DateTime fromPersianDate = pc.ToDateTime( - pc.GetYear(gregorianDate), - pc.GetMonth(gregorianDate), - pc.GetDayOfMonth(gregorianDate), - pc.GetHour(gregorianDate), - pc.GetMinute(gregorianDate), - pc.GetSecond(gregorianDate), - (int) pc.GetMilliseconds(gregorianDate), - PersianCalendar.PersianEra); - Console.WriteLine("The converted Gregorian calendar date is {0:G}", fromPersianDate); + // Define a Gregorian date of 3/21/2007 12:47:15 + DateTime gregorianDate = new DateTime(2007, 3, 21, 00, 47, 15); + Console.WriteLine("The Gregorian calendar date is {0:G}", gregorianDate); + // Convert the Gregorian date to its equivalent date in the Persian calendar + Console.WriteLine("The Persian calendar date is {0}/{1}/{2} {3}:{4}:{5}.", + pc.GetMonth(gregorianDate), + pc.GetDayOfMonth(gregorianDate), + pc.GetYear(gregorianDate), + pc.GetHour(gregorianDate), + pc.GetMinute(gregorianDate), + pc.GetSecond(gregorianDate)); + // Convert the Persian calendar date back to the Gregorian calendar date + DateTime fromPersianDate = pc.ToDateTime( + pc.GetYear(gregorianDate), + pc.GetMonth(gregorianDate), + pc.GetDayOfMonth(gregorianDate), + pc.GetHour(gregorianDate), + pc.GetMinute(gregorianDate), + pc.GetSecond(gregorianDate), + (int)pc.GetMilliseconds(gregorianDate), + PersianCalendar.PersianEra); + Console.WriteLine("The converted Gregorian calendar date is {0:G}", fromPersianDate); - // The code displays the following output to the console: - // - // The Gregorian calendar date is 3/21/2007 12:47:15 AM - // The Persian calendar date is 1/1/1386 0:47:15. - // The converted Gregorian calendar date is 3/21/2007 12:47:15 AM - // - } + // The code displays the following output to the console: + // + // The Gregorian calendar date is 3/21/2007 12:47:15 AM + // The Persian calendar date is 1/1/1386 0:47:15. + // The converted Gregorian calendar date is 3/21/2007 12:47:15 AM + // + } } diff --git a/snippets/csharp/System.Globalization/TextInfo/Clone/ro.cs b/snippets/csharp/System.Globalization/TextInfo/Clone/ro.cs index e5509602279..8c6860d2563 100644 --- a/snippets/csharp/System.Globalization/TextInfo/Clone/ro.cs +++ b/snippets/csharp/System.Globalization/TextInfo/Clone/ro.cs @@ -10,8 +10,8 @@ class Sample public static void Main() { // Get the TextInfo of a predefined culture that ships with -// the .NET Framework. - CultureInfo ci = new CultureInfo("en-US"); +// .NET. + CultureInfo ci = new("en-US"); TextInfo ti1 = ci.TextInfo; // Display whether the TextInfo is read-only or not. @@ -81,4 +81,4 @@ private static void DisplayReadOnly(string caption, TextInfo ti) 3d) The set operation is invalid. */ -// \ No newline at end of file +// diff --git a/snippets/csharp/System.Runtime.InteropServices/DllImportAttribute/PreserveSig/example.cs b/snippets/csharp/System.Runtime.InteropServices/DllImportAttribute/PreserveSig/example.cs index 28d80d887f4..3aef87407c3 100644 --- a/snippets/csharp/System.Runtime.InteropServices/DllImportAttribute/PreserveSig/example.cs +++ b/snippets/csharp/System.Runtime.InteropServices/DllImportAttribute/PreserveSig/example.cs @@ -1,20 +1,16 @@ // using System; -using System.Collections.Generic; using System.Runtime.InteropServices; internal class Win32 { // The SHAutoComplete function allows you // to add auto-compete functionality to your - // Windows Forms text boxes. In .NET Framework - // 1.1 and earlier, you can use SHAutoComplete. - // Later versions have this ability built in without - // requiring platform invoke. + // Windows Forms text boxes. - // See the MSDN documentation of the - // SHAutoComplete function for the - // complete set of flags. + // For the complete set of flags, + // see the documentation of the + // SHAutoComplete function. public enum SHAutoCompleteFlags { SHACF_DEFAULT = 0x00000000, @@ -70,4 +66,4 @@ static void Run() Console.WriteLine("HRESULT handled: " + HRESULT.ToString()); } } -// \ No newline at end of file +// diff --git a/snippets/csharp/System.Runtime.InteropServices/MarshalAsAttribute/SizeParamIndex/marshalas.sizeparamindex.cs b/snippets/csharp/System.Runtime.InteropServices/MarshalAsAttribute/SizeParamIndex/marshalas.sizeparamindex.cs index 6ea04ec8df4..65bc5dca308 100644 --- a/snippets/csharp/System.Runtime.InteropServices/MarshalAsAttribute/SizeParamIndex/marshalas.sizeparamindex.cs +++ b/snippets/csharp/System.Runtime.InteropServices/MarshalAsAttribute/SizeParamIndex/marshalas.sizeparamindex.cs @@ -5,7 +5,7 @@ namespace SomeNamespace { // Force the layout of your fields to the C style struct layout. - // Without this, the .NET Framework will reorder your fields. + // Without this, .NET will reorder your fields. [StructLayout(LayoutKind.Sequential)] public struct Vertex { @@ -41,4 +41,4 @@ public static void Main() AClass.SomeMethod(); } } -// \ No newline at end of file +// diff --git a/snippets/csharp/System.Runtime.InteropServices/StructLayoutAttribute/Pack/packex5.cs b/snippets/csharp/System.Runtime.InteropServices/StructLayoutAttribute/Pack/packex5.cs index 0b4445405d1..31555c07714 100644 --- a/snippets/csharp/System.Runtime.InteropServices/StructLayoutAttribute/Pack/packex5.cs +++ b/snippets/csharp/System.Runtime.InteropServices/StructLayoutAttribute/Pack/packex5.cs @@ -3,7 +3,6 @@ unsafe struct ExampleStruct5 { - public byte b1; public byte b2; public int i3; @@ -27,19 +26,10 @@ public unsafe static void Main() } // The example displays the following output: // -// .NET 5+: // Size: 32 // b1 Offset: 0 // b2 Offset: 1 // i3 Offset: 4 // a4 Offset: 8 // d5 Offset: 16 -// -// .NET Framework: -// Size: 28 -// b1 Offset: 0 -// b2 Offset: 1 -// i3 Offset: 4 -// a4 Offset: 8 -// d5 Offset: 12 // diff --git a/snippets/csharp/System.Runtime.InteropServices/StructLayoutAttribute/Pack/packex7.cs b/snippets/csharp/System.Runtime.InteropServices/StructLayoutAttribute/Pack/packex7.cs index b6cc4a8ec9c..dd497438a50 100644 --- a/snippets/csharp/System.Runtime.InteropServices/StructLayoutAttribute/Pack/packex7.cs +++ b/snippets/csharp/System.Runtime.InteropServices/StructLayoutAttribute/Pack/packex7.cs @@ -5,7 +5,6 @@ [StructLayout(LayoutKind.Sequential, Pack = 16)] unsafe struct ExampleStruct7 { - public byte b1; public byte b2; public int i3; @@ -29,19 +28,10 @@ public unsafe static void Main() } // The example displays the following output: // -// .NET 5+: // Size: 32 // b1 Offset: 0 // b2 Offset: 1 // i3 Offset: 4 // a4 Offset: 8 // d5 Offset: 16 -// -// .NET Framework: -// Size: 28 -// b1 Offset: 0 -// b2 Offset: 1 -// i3 Offset: 4 -// a4 Offset: 8 -// d5 Offset: 12 // diff --git a/snippets/csharp/System.Runtime.Versioning/FrameworkName/op_Equality/Operators1.cs b/snippets/csharp/System.Runtime.Versioning/FrameworkName/op_Equality/Operators1.cs index 2e203d8652a..af2bfedfff5 100644 --- a/snippets/csharp/System.Runtime.Versioning/FrameworkName/op_Equality/Operators1.cs +++ b/snippets/csharp/System.Runtime.Versioning/FrameworkName/op_Equality/Operators1.cs @@ -3,51 +3,57 @@ public class Example { - public static void Main() - { - TestForEquality(); - TestForInequality(); - } - - private static void TestForEquality() - { - // - FrameworkName supportedVer1 = new FrameworkName(".NET Framework, Version=4.0"); - FrameworkName actualVersion = new FrameworkName(String.Format( - ".NET Framework, Version={0}", - Environment.Version.ToString())); - - Console.WriteLine("Supported Version: {0}", supportedVer1); - Console.WriteLine("Actual Version: {0}", actualVersion); - if (supportedVer1 == actualVersion) - Console.WriteLine("The supported and actual Framework versions are the same."); - else - Console.WriteLine("The supported and actual Framework versions are different."); - - Console.WriteLine(); - // The example displays the following output: - // The supported and actual Framework versions are different. - // - } - - private static void TestForInequality() - { - // - FrameworkName supportedVer1 = new FrameworkName(".NET Framework, Version=4.0"); - FrameworkName actualVersion = new FrameworkName(String.Format( - ".NET Framework, Version={0}", - Environment.Version.ToString())); - - Console.WriteLine("Supported Version: {0}", supportedVer1); - Console.WriteLine("Actual Version: {0}", actualVersion); - if (supportedVer1 != actualVersion) - Console.WriteLine("The supported and actual Framework versions are different."); - else - Console.WriteLine("The supported and actual Framework versions are the same."); - - Console.WriteLine(); - // The example displays the following output: - // The supported and actual Framework versions are different. - // - } + public static void Main() + { + TestForEquality(); + TestForInequality(); + } + + private static void TestForEquality() + { + // + FrameworkName version = new(".NET, Version=10.0"); + FrameworkName actualVersion = new($".NET, Version={Environment.Version}"); + + Console.WriteLine($"Given Version: {version}"); + Console.WriteLine($"Actual Version: {actualVersion}"); + if (version == actualVersion) + Console.WriteLine("The versions are the same."); + else + Console.WriteLine("The versions are different."); + + Console.WriteLine(); + + // The example displays output similar to the following: + + // Given Version: .NET,Version=v10.0 + // Actual Version: .NET,Version=v10.0.10 + // The versions are different. + + // + } + + private static void TestForInequality() + { + // + FrameworkName version = new(".NET, Version=10.0"); + FrameworkName actualVersion = new($".NET, Version={Environment.Version}"); + + Console.WriteLine($"Given Version: {version}"); + Console.WriteLine($"Actual Version {actualVersion}"); + if (version != actualVersion) + Console.WriteLine("The versions are different."); + else + Console.WriteLine("The versions are the same."); + + Console.WriteLine(); + + // The example displays output similar to the following: + + // Given Version: .NET,Version=v10.0 + // Actual Version: .NET,Version=v10.0.10 + // The versions are different. + + // + } } diff --git a/snippets/csharp/System.Runtime.Versioning/FrameworkName/op_Equality/Project.csproj b/snippets/csharp/System.Runtime.Versioning/FrameworkName/op_Equality/Project.csproj index a369cfa8a80..ffb97e9872d 100644 --- a/snippets/csharp/System.Runtime.Versioning/FrameworkName/op_Equality/Project.csproj +++ b/snippets/csharp/System.Runtime.Versioning/FrameworkName/op_Equality/Project.csproj @@ -1,7 +1,7 @@ - Library + Exe net10.0 diff --git a/snippets/csharp/System.ServiceProcess/SessionChangeDescription/Overview/simpleservice.cs b/snippets/csharp/System.ServiceProcess/SessionChangeDescription/Overview/simpleservice.cs index f6e9bd05732..61525081bba 100644 --- a/snippets/csharp/System.ServiceProcess/SessionChangeDescription/Overview/simpleservice.cs +++ b/snippets/csharp/System.ServiceProcess/SessionChangeDescription/Overview/simpleservice.cs @@ -156,8 +156,7 @@ protected override void OnStart(string[] args) // Stop this service. protected override void OnStop() { - // New in .NET Framework version 2.0. - this.RequestAdditionalTime(4000); + RequestAdditionalTime(4000); // Signal the worker thread to exit. if ((workerThread != null) && (workerThread.IsAlive)) { diff --git a/snippets/csharp/System.Text/EncodingInfo/Overview/encodinginfo.cs b/snippets/csharp/System.Text/EncodingInfo/Overview/encodinginfo.cs index c14e5789bd1..e0a0cbc2399 100644 --- a/snippets/csharp/System.Text/EncodingInfo/Overview/encodinginfo.cs +++ b/snippets/csharp/System.Text/EncodingInfo/Overview/encodinginfo.cs @@ -41,162 +41,19 @@ public static void Main() { } } } -/* -The example produces the following output when run on .NET Core: -Info.CodePage Info.Name Info.DisplayName -1200 utf-16 Unicode -1201 utf-16BE Unicode (Big-Endian) -12000 utf-32 Unicode (UTF-32) -12001 utf-32BE Unicode (UTF-32 Big-Endian) -20127 us-ascii US-ASCII -28591 iso-8859-1 Western European (ISO) -65000 utf-7 Unicode (UTF-7) -65001 utf-8 Unicode (UTF-8) - -The example produces the following output when run on .NET Framework: +/* +The example produces the following output: Info.CodePage Info.Name Info.DisplayName -37 IBM037 IBM EBCDIC (US-Canada) -437 IBM437 OEM United States -500 IBM500 IBM EBCDIC (International) -708 ASMO-708 Arabic (ASMO 708) -720 DOS-720 Arabic (DOS) -737 ibm737 Greek (DOS) -775 ibm775 Baltic (DOS) -850 ibm850 Western European (DOS) -852 ibm852 Central European (DOS) -855 IBM855 OEM Cyrillic -857 ibm857 Turkish (DOS) -858 IBM00858 OEM Multilingual Latin I -860 IBM860 Portuguese (DOS) -861 ibm861 Icelandic (DOS) -862 DOS-862 Hebrew (DOS) -863 IBM863 French Canadian (DOS) -864 IBM864 Arabic (864) -865 IBM865 Nordic (DOS) -866 cp866 Cyrillic (DOS) -869 ibm869 Greek, Modern (DOS) -870 IBM870 IBM EBCDIC (Multilingual Latin-2) -874 windows-874 Thai (Windows) -875 cp875 IBM EBCDIC (Greek Modern) -932 shift_jis Japanese (Shift-JIS) -936 gb2312 Chinese Simplified (GB2312) -949 ks_c_5601-1987 Korean -950 big5 Chinese Traditional (Big5) -1026 IBM1026 IBM EBCDIC (Turkish Latin-5) -1047 IBM01047 IBM Latin-1 -1140 IBM01140 IBM EBCDIC (US-Canada-Euro) -1141 IBM01141 IBM EBCDIC (Germany-Euro) -1142 IBM01142 IBM EBCDIC (Denmark-Norway-Euro) -1143 IBM01143 IBM EBCDIC (Finland-Sweden-Euro) -1144 IBM01144 IBM EBCDIC (Italy-Euro) -1145 IBM01145 IBM EBCDIC (Spain-Euro) -1146 IBM01146 IBM EBCDIC (UK-Euro) -1147 IBM01147 IBM EBCDIC (France-Euro) -1148 IBM01148 IBM EBCDIC (International-Euro) -1149 IBM01149 IBM EBCDIC (Icelandic-Euro) -1200 utf-16 Unicode -1201 utf-16BE Unicode (Big-Endian) -1250 windows-1250 Central European (Windows) -1251 windows-1251 Cyrillic (Windows) -1252 Windows-1252 Western European (Windows) -1253 windows-1253 Greek (Windows) -1254 windows-1254 Turkish (Windows) -1255 windows-1255 Hebrew (Windows) -1256 windows-1256 Arabic (Windows) -1257 windows-1257 Baltic (Windows) -1258 windows-1258 Vietnamese (Windows) -1361 Johab Korean (Johab) -10000 macintosh Western European (Mac) -10001 x-mac-japanese Japanese (Mac) -10002 x-mac-chinesetrad Chinese Traditional (Mac) -10003 x-mac-korean Korean (Mac) -10004 x-mac-arabic Arabic (Mac) -10005 x-mac-hebrew Hebrew (Mac) -10006 x-mac-greek Greek (Mac) -10007 x-mac-cyrillic Cyrillic (Mac) -10008 x-mac-chinesesimp Chinese Simplified (Mac) -10010 x-mac-romanian Romanian (Mac) -10017 x-mac-ukrainian Ukrainian (Mac) -10021 x-mac-thai Thai (Mac) -10029 x-mac-ce Central European (Mac) -10079 x-mac-icelandic Icelandic (Mac) -10081 x-mac-turkish Turkish (Mac) -10082 x-mac-croatian Croatian (Mac) -12000 utf-32 Unicode (UTF-32) -12001 utf-32BE Unicode (UTF-32 Big-Endian) -20000 x-Chinese-CNS Chinese Traditional (CNS) -20001 x-cp20001 TCA Taiwan -20002 x-Chinese-Eten Chinese Traditional (Eten) -20003 x-cp20003 IBM5550 Taiwan -20004 x-cp20004 TeleText Taiwan -20005 x-cp20005 Wang Taiwan -20105 x-IA5 Western European (IA5) -20106 x-IA5-German German (IA5) -20107 x-IA5-Swedish Swedish (IA5) -20108 x-IA5-Norwegian Norwegian (IA5) -20127 us-ascii US-ASCII -20261 x-cp20261 T.61 -20269 x-cp20269 ISO-6937 -20273 IBM273 IBM EBCDIC (Germany) -20277 IBM277 IBM EBCDIC (Denmark-Norway) -20278 IBM278 IBM EBCDIC (Finland-Sweden) -20280 IBM280 IBM EBCDIC (Italy) -20284 IBM284 IBM EBCDIC (Spain) -20285 IBM285 IBM EBCDIC (UK) -20290 IBM290 IBM EBCDIC (Japanese katakana) -20297 IBM297 IBM EBCDIC (France) -20420 IBM420 IBM EBCDIC (Arabic) -20423 IBM423 IBM EBCDIC (Greek) -20424 IBM424 IBM EBCDIC (Hebrew) -20833 x-EBCDIC-KoreanExtended IBM EBCDIC (Korean Extended) -20838 IBM-Thai IBM EBCDIC (Thai) -20866 koi8-r Cyrillic (KOI8-R) -20871 IBM871 IBM EBCDIC (Icelandic) -20880 IBM880 IBM EBCDIC (Cyrillic Russian) -20905 IBM905 IBM EBCDIC (Turkish) -20924 IBM00924 IBM Latin-1 -20932 EUC-JP Japanese (JIS 0208-1990 and 0212-1990) -20936 x-cp20936 Chinese Simplified (GB2312-80) -20949 x-cp20949 Korean Wansung -21025 cp1025 IBM EBCDIC (Cyrillic Serbian-Bulgarian) -21866 koi8-u Cyrillic (KOI8-U) -28591 iso-8859-1 Western European (ISO) -28592 iso-8859-2 Central European (ISO) -28593 iso-8859-3 Latin 3 (ISO) -28594 iso-8859-4 Baltic (ISO) -28595 iso-8859-5 Cyrillic (ISO) -28596 iso-8859-6 Arabic (ISO) -28597 iso-8859-7 Greek (ISO) -28598 iso-8859-8 Hebrew (ISO-Visual) -28599 iso-8859-9 Turkish (ISO) -28603 iso-8859-13 Estonian (ISO) -28605 iso-8859-15 Latin 9 (ISO) -29001 x-Europa Europa -38598 iso-8859-8-i Hebrew (ISO-Logical) -50220 iso-2022-jp Japanese (JIS) -50221 csISO2022JP Japanese (JIS-Allow 1 byte Kana) -50222 iso-2022-jp Japanese (JIS-Allow 1 byte Kana - SO/SI) -50225 iso-2022-kr Korean (ISO) -50227 x-cp50227 Chinese Simplified (ISO-2022) -51932 euc-jp Japanese (EUC) -51936 EUC-CN Chinese Simplified (EUC) -51949 euc-kr Korean (EUC) -52936 hz-gb-2312 Chinese Simplified (HZ) -54936 GB18030 Chinese Simplified (GB18030) -57002 x-iscii-de ISCII Devanagari -57003 x-iscii-be ISCII Bengali -57004 x-iscii-ta ISCII Tamil -57005 x-iscii-te ISCII Telugu -57006 x-iscii-as ISCII Assamese -57007 x-iscii-or ISCII Oriya -57008 x-iscii-ka ISCII Kannada -57009 x-iscii-ma ISCII Malayalam -57010 x-iscii-gu ISCII Gujarati -57011 x-iscii-pa ISCII Punjabi -65000 utf-7 Unicode (UTF-7) -65001 utf-8 Unicode (UTF-8) +1200 utf-16 Unicode +1201 utf-16BE Unicode (Big-Endian) +12000 utf-32 Unicode (UTF-32) +12001 utf-32BE Unicode (UTF-32 Big-Endian) +20127 us-ascii US-ASCII +28591 iso-8859-1 Western European (ISO) +65000 utf-7 Unicode (UTF-7) +65001 utf-8 Unicode (UTF-8) */ // diff --git a/snippets/csharp/System.Text/StringBuilder/Capacity/cap.cs b/snippets/csharp/System.Text/StringBuilder/Capacity/cap.cs index 560ccd6d6bc..6fc1ab7fcb0 100644 --- a/snippets/csharp/System.Text/StringBuilder/Capacity/cap.cs +++ b/snippets/csharp/System.Text/StringBuilder/Capacity/cap.cs @@ -50,7 +50,7 @@ Ensure sb1 has a capacity of at least 50 characters. b1) sb1.Length = 3, sb1.Capacity = 50 b2) sb2.Length = 3, sb2.Capacity = 16 b3) sb1.ToString() = "abc", sb2.ToString() = "abc" -b4) sb1 equals sb2: True (False on .NET Framework) +b4) sb1 equals sb2: True Set the length of sb1 to zero. Set the capacity of sb2 to 51 characters. diff --git a/snippets/csharp/System.Threading/SpinWait/Overview/spinwait.cs b/snippets/csharp/System.Threading/SpinWait/Overview/spinwait.cs index 2ae8355e29b..b5fd297ff13 100644 --- a/snippets/csharp/System.Threading/SpinWait/Overview/spinwait.cs +++ b/snippets/csharp/System.Threading/SpinWait/Overview/spinwait.cs @@ -28,7 +28,7 @@ static void Main() sw.SpinOnce(); } - // As of .NET Framework 4: After some initial spinning, SpinWait.SpinOnce() will yield every time. + // After some initial spinning, SpinWait.SpinOnce() will yield every time. Console.WriteLine("SpinWait called {0} times, yielded {1} times", sw.Count, numYields); }); @@ -43,4 +43,4 @@ static void Main() Task.WaitAll(t1, t2); } } -// \ No newline at end of file +// diff --git a/snippets/csharp/System.Threading/ThreadStart/Overview/source.cs b/snippets/csharp/System.Threading/ThreadStart/Overview/source.cs index 1d65a4bda90..7d67938d882 100644 --- a/snippets/csharp/System.Threading/ThreadStart/Overview/source.cs +++ b/snippets/csharp/System.Threading/ThreadStart/Overview/source.cs @@ -4,51 +4,50 @@ class Test { - static void Main() + static void Main() { // To start a thread using a static thread procedure, use the // class name and method name when you create the ThreadStart - // delegate. Beginning in version 2.0 of the .NET Framework, - // it is not necessary to create a delegate explicitly. - // Specify the name of the method in the Thread constructor, + // delegate. It's not necessary to create a delegate explicitly. + // Specify the name of the method in the Thread constructor, // and the compiler selects the correct delegate. For example: // // Thread newThread = new Thread(Work.DoWork); // - ThreadStart threadDelegate = new ThreadStart(Work.DoWork); - Thread newThread = new Thread(threadDelegate); + ThreadStart threadDelegate = new(Work.DoWork); + Thread newThread = new(threadDelegate); newThread.Start(); - // To start a thread using an instance method for the thread - // procedure, use the instance variable and method name when - // you create the ThreadStart delegate. Beginning in version - // 2.0 of the .NET Framework, the explicit delegate is not - // required. - // - Work w = new Work(); - w.Data = 42; + // To start a thread using an instance method for the thread + // procedure, use the instance variable and method name when + // you create the ThreadStart delegate. + Work w = new() + { + Data = 42 + }; threadDelegate = new ThreadStart(w.DoMoreWork); newThread = new Thread(threadDelegate); newThread.Start(); } } -class Work +class Work { - public static void DoWork() + public static void DoWork() { - Console.WriteLine("Static thread procedure."); + Console.WriteLine("Static thread procedure."); } public int Data; - public void DoMoreWork() + public void DoMoreWork() { - Console.WriteLine("Instance thread procedure. Data={0}", Data); + Console.WriteLine("Instance thread procedure. Data={0}", Data); } } -/* This code example produces the following output (the order +/* This code example produces the following output (the order of the lines might vary): Static thread procedure. Instance thread procedure. Data=42 */ -// \ No newline at end of file + +// diff --git a/snippets/csharp/System.Windows/Application/Overview/CSharp.csproj b/snippets/csharp/System.Windows/Application/Overview/CSharp.csproj index 5849c290b5b..d938b08ed22 100644 --- a/snippets/csharp/System.Windows/Application/Overview/CSharp.csproj +++ b/snippets/csharp/System.Windows/Application/Overview/CSharp.csproj @@ -1,107 +1,11 @@ - + - Debug - AnyCPU - {D4982CD9-4444-4BB5-B4AC-2D9AB41B87DA} - {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + WinExe + net10.0-windows SDKSample CSharp - 4 - winexe - - v4.8 - http://localhost/CSharp/ - true - Web - true - Foreground - 7 - Days - false - false - true - 0 - 1.0.0.%2a - true - false - false - - 10.0.20821 + true + enable + SDKSample.App - - true - full - false - .\bin\Debug\ - DEBUG;TRACE - - - false - true - .\bin\Release\ - TRACE - - - - - - - - - - - 4.0 - - - - - - - - - - - - MSBuild:Compile - Designer - - - App.xaml - Code - - - - - - - - - - MSBuild:Compile - Designer - - - - - False - .NET Framework 2.0 %28x86%29 - false - - - False - .NET Framework 3.0 %28x86%29 - true - - - False - .NET Framework 3.5 - false - - - False - Windows Installer 3.1 - true - - - - \ No newline at end of file + diff --git a/snippets/csharp/System.Windows/Application/Overview/Properties/AssemblyInfo.cs b/snippets/csharp/System.Windows/Application/Overview/Properties/AssemblyInfo.cs index a5bef1700cd..1a1d3e0a97a 100644 --- a/snippets/csharp/System.Windows/Application/Overview/Properties/AssemblyInfo.cs +++ b/snippets/csharp/System.Windows/Application/Overview/Properties/AssemblyInfo.cs @@ -12,17 +12,9 @@ // General Information about an assembly is controlled through the following // set of attributes. Change these attribute values to modify the information // associated with an assembly. -[assembly: AssemblyTitle("CSharp")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("Microsoft")] -[assembly: AssemblyProduct("CSharp")] -[assembly: AssemblyCopyright("Copyright @ Microsoft 2006")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] [assembly: ComVisible(false)] -//In order to begin building localizable applications, set +//To begin building localizable applications, set //CultureYouAreCodingWith in your .csproj file //inside a . For example, if you are using US english //in your source files, set the to en-US. Then uncomment @@ -49,4 +41,4 @@ // // You can specify all the values or you can default the Revision and Build Numbers // by using the '*' as shown below: -[assembly: AssemblyVersion("1.0.*")] +// [assembly: AssemblyVersion("1.0.0.0")] diff --git a/snippets/csharp/System/Console/Overview/example3.cs b/snippets/csharp/System/Console/Overview/example3.cs index 852dbee4cc5..05e7487ae35 100644 --- a/snippets/csharp/System/Console/Overview/example3.cs +++ b/snippets/csharp/System/Console/Overview/example3.cs @@ -42,8 +42,8 @@ private static void Main(string[] args) return; } - if (setOutputEncodingToUnicode) { - // This won't work before .NET Framework 4.5. + if (setOutputEncodingToUnicode) + { try { // Set encoding using endianness of this system. // We're interested in displaying individual Char objects, so diff --git a/snippets/csharp/System/Convert/ToBoolean/system.convert snippet.cs b/snippets/csharp/System/Convert/ToBoolean/system.convert snippet.cs index 588a0840725..343d3880bc4 100644 --- a/snippets/csharp/System/Convert/ToBoolean/system.convert snippet.cs +++ b/snippets/csharp/System/Convert/ToBoolean/system.convert snippet.cs @@ -5,7 +5,7 @@ namespace BasicSnippetC { class ConvertSnippet { static void Main(string[] args) { - + ConvertSnippet snippet = new ConvertSnippet(); double doubleVal; @@ -68,7 +68,7 @@ public void ConvertBytes(byte byteVal) { ConvertByteDecimal(byteVal); ConvertByteSingle(byteVal); } - + // public void ConvertDoubleBool(double doubleVal) { bool boolVal; @@ -108,7 +108,7 @@ public void ConvertDoubleByte(double doubleVal) { // public void ConvertDoubleInt(double doubleVal) { - + int intVal = 0; // Double to int conversion can overflow. try { @@ -127,12 +127,12 @@ public void ConvertDoubleInt(double doubleVal) { intVal, doubleVal); } // - + // public void ConvertDoubleDecimal(decimal decimalVal){ - + double doubleVal; - + // Decimal to double conversion cannot overflow. doubleVal = System.Convert.ToDouble(decimalVal); System.Console.WriteLine("{0} as a double is: {1}", @@ -153,7 +153,7 @@ public void ConvertDoubleDecimal(decimal decimalVal){ // // - public void CovertDoubleFloat(double doubleVal) { + public void CovertDoubleFloat(double doubleVal) { float floatVal = 0; // Double to float conversion cannot overflow. @@ -167,10 +167,10 @@ public void CovertDoubleFloat(double doubleVal) { floatVal, doubleVal); } // - + // public void ConvertDoubleString(double doubleVal) { - + string stringVal; // A conversion from Double to string cannot overflow. @@ -212,7 +212,7 @@ public void ConvertLongChar(long longVal) { System.Console.WriteLine( "Overflow in long-to-char conversion."); } - + // A conversion from Char to long cannot overflow. longVal = System.Convert.ToInt64(charVal); System.Console.WriteLine("{0} as an Int64 is {1}", @@ -235,7 +235,7 @@ public void ConvertLongByte(long longVal) { System.Console.WriteLine( "Overflow in long-to-byte conversion."); } - + // A conversion from Byte to long cannot overflow. longVal = System.Convert.ToInt64(byteVal); System.Console.WriteLine("{0} as an Int64 is {1}", @@ -247,7 +247,7 @@ public void ConvertLongByte(long longVal) { public void ConvertLongDecimal(long longVal) { decimal decimalVal; - + // Long to decimal conversion cannot overflow. decimalVal = System.Convert.ToDecimal(longVal); System.Console.WriteLine("{0} as a decimal is {1}", @@ -270,12 +270,12 @@ public void ConvertLongDecimal(long longVal) { public void ConvertLongFloat(long longVal) { float floatVal; - + // A conversion from Long to float cannot overflow. floatVal = System.Convert.ToSingle(longVal); System.Console.WriteLine("{0} as a float is {1}", longVal, floatVal); - + // A conversion from float to long can overflow. try { longVal = System.Convert.ToInt64(floatVal); @@ -291,7 +291,7 @@ public void ConvertLongFloat(long longVal) { // public void ConvertStringBoolean(string stringVal) { - + bool boolVal = false; try { @@ -321,7 +321,7 @@ public void ConvertStringBoolean(string stringVal) { // public void ConvertStringByte(string stringVal) { byte byteVal = 0; - + try { byteVal = System.Convert.ToByte(stringVal); System.Console.WriteLine("{0} as a byte is: {1}", @@ -346,7 +346,7 @@ public void ConvertStringByte(string stringVal) { byteVal, stringVal); } // - + // public void ConvertStringChar(string stringVal) { char charVal = 'a'; @@ -371,11 +371,11 @@ public void ConvertStringChar(string stringVal) { stringVal); } // - + // public void ConvertStringDecimal(string stringVal) { decimal decimalVal = 0; - + try { decimalVal = System.Convert.ToDecimal(stringVal); System.Console.WriteLine( @@ -398,13 +398,13 @@ public void ConvertStringDecimal(string stringVal) { stringVal = System.Convert.ToString(decimalVal); System.Console.WriteLine( "The decimal as a string is {0}.", stringVal); - } + } // // public void ConvertStringFloat(string stringVal) { float floatVal = 0; - + try { floatVal = System.Convert.ToSingle(stringVal); System.Console.WriteLine( @@ -433,7 +433,7 @@ public void ConvertStringFloat(string stringVal) { // public void ConvertCharDecimal(char charVal) { Decimal decimalVal = 0; - + // Char to decimal conversion is not supported and will always // throw an InvalidCastException. try { @@ -441,8 +441,7 @@ public void ConvertCharDecimal(char charVal) { } catch (System.InvalidCastException) { System.Console.WriteLine( - "Char-to-Decimal conversion is not supported " + - "by the .NET Framework."); + "Char-to-Decimal conversion is not supported by .NET."); } //Decimal to char conversion is also not supported. @@ -451,8 +450,7 @@ public void ConvertCharDecimal(char charVal) { } catch (System.InvalidCastException) { System.Console.WriteLine( - "Decimal-to-Char conversion is not supported " + - "by the .NET Framework."); + "Decimal-to-Char conversion is not supported by .NET."); } } // @@ -513,7 +511,7 @@ public void ConvertBoolean() { DateTime dateTime = new DateTime(year, month, day, hour, minute, second, millisecond); - + bool boolVal; // System.InvalidCastException is always thrown. @@ -522,7 +520,7 @@ public void ConvertBoolean() { } catch (System.InvalidCastException) { System.Console.WriteLine("Conversion from DateTime to " + - "Boolean is not supported by the .NET Framework."); + "Boolean is not supported by .NET."); } } // diff --git a/snippets/csharp/System/Single/Overview/Program.cs b/snippets/csharp/System/Single/Overview/Program.cs new file mode 100644 index 00000000000..5a31894d3c4 --- /dev/null +++ b/snippets/csharp/System/Single/Overview/Program.cs @@ -0,0 +1 @@ +Example.Main(); diff --git a/snippets/csharp/System/Single/Overview/Project.csproj b/snippets/csharp/System/Single/Overview/Project.csproj index 258b56c95b9..f99395b4b2b 100644 --- a/snippets/csharp/System/Single/Overview/Project.csproj +++ b/snippets/csharp/System/Single/Overview/Project.csproj @@ -3,7 +3,6 @@ Exe net10.0 - Example1 diff --git a/snippets/csharp/System/Single/Overview/comparison2.cs b/snippets/csharp/System/Single/Overview/comparison2.cs index 3282246945f..c18df56a7fa 100644 --- a/snippets/csharp/System/Single/Overview/comparison2.cs +++ b/snippets/csharp/System/Single/Overview/comparison2.cs @@ -11,10 +11,9 @@ public static void Main() value2 = ((float)Math.Sqrt(value2)) / 3.51f; Console.WriteLine($"{value1} = {value2}: {value1.Equals(value2)}"); - // The example displays the following output on .NET: + // The example displays the following output on modern .NET: // 10.201438 = 10.201439: False - // The example displays the following output on .NET Framework: - // 10.20144 = 10.20144: False + // } } diff --git a/snippets/csharp/System/Single/Overview/precisionlist3.cs b/snippets/csharp/System/Single/Overview/precisionlist3.cs index d05493e8b93..c8f2421707d 100644 --- a/snippets/csharp/System/Single/Overview/precisionlist3.cs +++ b/snippets/csharp/System/Single/Overview/precisionlist3.cs @@ -18,8 +18,7 @@ public static void Main() } } -// The example displays the following output on .NET: +// The example displays the following output on modern .NET: // The sum of the values (27.650002) does not equal the total (27.65). -// The example displays the following output on .NET Framework: -// The sum of the values (27.65) does not equal the total (27.65). + // diff --git a/snippets/csharp/System/Single/Overview/precisionlist4a.cs b/snippets/csharp/System/Single/Overview/precisionlist4a.cs deleted file mode 100644 index 299b38273f9..00000000000 --- a/snippets/csharp/System/Single/Overview/precisionlist4a.cs +++ /dev/null @@ -1,35 +0,0 @@ -using System; -using System.IO; - -public class Example10 -{ - public static void Main() - { - // - StreamWriter sw = new(@"./Singles.dat"); - float[] values = { 3.2f / 1.11f, 1.0f / 3f, (float)Math.PI }; - for (int ctr = 0; ctr < values.Length; ctr++) - { - sw.Write(values[ctr].ToString()); - if (ctr != values.Length - 1) - sw.Write("|"); - } - sw.Close(); - - float[] restoredValues = new float[values.Length]; - StreamReader sr = new(@"./Singles.dat"); - string temp = sr.ReadToEnd(); - string[] tempStrings = temp.Split('|'); - for (int ctr = 0; ctr < tempStrings.Length; ctr++) - restoredValues[ctr] = float.Parse(tempStrings[ctr]); - - for (int ctr = 0; ctr < values.Length; ctr++) - Console.WriteLine($"{values[ctr]} {(values[ctr].Equals(restoredValues[ctr]) ? "=" : "<>")} {restoredValues[ctr]}"); - - // The example displays the following output on .NET Framework: - // 2.882883 <> 2.882883 - // 0.3333333 <> 0.3333333 - // 3.141593 <> 3.141593 - // - } -} diff --git a/snippets/csharp/System/String/IndexOf/ignorable21.cs b/snippets/csharp/System/String/IndexOf/ignorable21.cs index 36e0ee1abab..29b182f331b 100644 --- a/snippets/csharp/System/String/IndexOf/ignorable21.cs +++ b/snippets/csharp/System/String/IndexOf/ignorable21.cs @@ -7,21 +7,21 @@ public static void Main() { string s1 = "ani\u00ADmal"; string s2 = "animal"; - + // Find the index of the soft hyphen. Console.WriteLine(s1.IndexOf("\u00AD")); Console.WriteLine(s2.IndexOf("\u00AD")); - + // Find the index of the soft hyphen followed by "n". Console.WriteLine(s1.IndexOf("\u00ADn")); Console.WriteLine(s2.IndexOf("\u00ADn")); - + // Find the index of the soft hyphen followed by "m". Console.WriteLine(s1.IndexOf("\u00ADm")); Console.WriteLine(s2.IndexOf("\u00ADm")); - // The example displays the following output - // if run under the .NET Framework 4 or later: + // The example displays the following output: + // // 0 // 0 // 1 diff --git a/snippets/csharp/System/TimeSpan/Parse/parsefailure1.cs b/snippets/csharp/System/TimeSpan/Parse/parsefailure1.cs deleted file mode 100644 index 8ddbd82d5f0..00000000000 --- a/snippets/csharp/System/TimeSpan/Parse/parsefailure1.cs +++ /dev/null @@ -1,31 +0,0 @@ -using System; - -public class Example3 -{ - public static void Main() - { - // - string[] values = { "000000006", "12.12:12:12.12345678" }; - foreach (string value in values) - { - try { - TimeSpan interval = TimeSpan.Parse(value); - Console.WriteLine($"{value} --> {interval}"); - } - catch (FormatException) { - Console.WriteLine($"{value}: Bad Format"); - } - catch (OverflowException) { - Console.WriteLine($"{value}: Overflow"); - } - } - - // Output from .NET Framework 3.5 and earlier versions: - // 000000006 --> 6.00:00:00 - // 12.12:12:12.12345678: Bad Format - // Output from .NET Framework 4 and later versions or .NET Core: - // 000000006: Overflow - // 12.12:12:12.12345678: Overflow - // - } -} diff --git a/snippets/csharp/System/Type/Assembly/type_assembly.cs b/snippets/csharp/System/Type/Assembly/type_assembly.cs index 81a90a550ad..6174c11a0ba 100644 --- a/snippets/csharp/System/Type/Assembly/type_assembly.cs +++ b/snippets/csharp/System/Type/Assembly/type_assembly.cs @@ -1,10 +1,10 @@ -// -using System; +using System; class MyAssemblyClass { public static void Main() { + // Type objType = typeof(Array); // Print the assembly full name. @@ -12,11 +12,14 @@ public static void Main() // Print the assembly qualified name. Console.WriteLine($"Assembly qualified name:\n {objType.AssemblyQualifiedName}."); + + // The example displays output similar to the following: + // + // Assembly full name: + // System.Private.CoreLib, Version = 10.0.0.0, Culture = neutral, PublicKeyToken = 7cec85d7bea7798e. + // Assembly qualified name: + // System.Array, System.Private.CoreLib, Version = 10.0.0.0, Culture = neutral, PublicKeyToken = 7cec85d7bea7798e. + + // } } -// The example displays the following output if run under the .NET Framework 4.5: -// Assembly full name: -// mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089. -// Assembly qualified name: -// System.Array, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089. -// diff --git a/snippets/fsharp/System.Diagnostics/DataReceivedEventArgs/Overview/net_async.fs b/snippets/fsharp/System.Diagnostics/DataReceivedEventArgs/Overview/net_async.fs index 4a6df39ee9f..fb2364d5ad2 100644 --- a/snippets/fsharp/System.Diagnostics/DataReceivedEventArgs/Overview/net_async.fs +++ b/snippets/fsharp/System.Diagnostics/DataReceivedEventArgs/Overview/net_async.fs @@ -1,7 +1,4 @@ module netasync -// System.Diagnostics -// -// Requires .NET Framework version 1.2 or higher. // The following example uses the net view command to list the // available network resources available on a remote computer, diff --git a/snippets/fsharp/System.Diagnostics/DataReceivedEventArgs/Overview/nmake_async.fs b/snippets/fsharp/System.Diagnostics/DataReceivedEventArgs/Overview/nmake_async.fs index ee5220c9a34..0da50396734 100644 --- a/snippets/fsharp/System.Diagnostics/DataReceivedEventArgs/Overview/nmake_async.fs +++ b/snippets/fsharp/System.Diagnostics/DataReceivedEventArgs/Overview/nmake_async.fs @@ -1,7 +1,4 @@ module nmakeasync -// System.Diagnostics -// -// Requires .NET Framework version 1.2 or higher. // Define the namespaces used by this sample. open System diff --git a/snippets/fsharp/System.Diagnostics/DataReceivedEventArgs/Overview/sort_async.fs b/snippets/fsharp/System.Diagnostics/DataReceivedEventArgs/Overview/sort_async.fs index 135a8d86d10..54b8d766648 100644 --- a/snippets/fsharp/System.Diagnostics/DataReceivedEventArgs/Overview/sort_async.fs +++ b/snippets/fsharp/System.Diagnostics/DataReceivedEventArgs/Overview/sort_async.fs @@ -1,7 +1,4 @@ module sortasync -// System.Diagnostics -// -// Requires .NET Framework version 1.2 or higher. // The following example uses the sort command to sort a list // of input text lines, and displays the sorted list to the console. diff --git a/snippets/fsharp/System.Text/StringBuilder/Capacity/cap.fs b/snippets/fsharp/System.Text/StringBuilder/Capacity/cap.fs index f75123c98f6..b9919d55d82 100644 --- a/snippets/fsharp/System.Text/StringBuilder/Capacity/cap.fs +++ b/snippets/fsharp/System.Text/StringBuilder/Capacity/cap.fs @@ -38,17 +38,17 @@ printfn $"c4) sb1 equals sb2: {sb1.Equals sb2}" // a4) sb1 equals sb2: True // // Ensure sb1 has a capacity of at least 50 characters. -// +// // b1) sb1.Length = 3, sb1.Capacity = 50 // b2) sb2.Length = 3, sb2.Capacity = 16 // b3) sb1.ToString() = "abc", sb2.ToString() = "abc" -// b4) sb1 equals sb2: True (False on .NET Framework) -// +// b4) sb1 equals sb2: True +// // Set the length of sb1 to zero. // Set the capacity of sb2 to 51 characters. -// +// // c1) sb1.Length = 0, sb1.Capacity = 50 // c2) sb2.Length = 3, sb2.Capacity = 51 // c3) sb1.ToString() = "", sb2.ToString() = "abc" // c4) sb1 equals sb2: False -// \ No newline at end of file +// diff --git a/snippets/fsharp/System/Console/Overview/example3.fs b/snippets/fsharp/System/Console/Overview/example3.fs index 5ff62571827..8b97c7c9e5d 100644 --- a/snippets/fsharp/System/Console/Overview/example3.fs +++ b/snippets/fsharp/System/Console/Overview/example3.fs @@ -117,7 +117,6 @@ let main args = | None -> () | Some parsedArgs -> if parsedArgs.setOutputEncodingToUnicode then - // This won't work before .NET Framework 4.5. try // Set encoding using endianness of this system. // We're interested in displaying individual Char objects, so diff --git a/snippets/fsharp/System/Double/Overview/precision1.fs b/snippets/fsharp/System/Double/Overview/precision1.fs index 7af7fc844d3..f8250712965 100644 --- a/snippets/fsharp/System/Double/Overview/precision1.fs +++ b/snippets/fsharp/System/Double/Overview/precision1.fs @@ -12,13 +12,17 @@ let fromParse = Double.Parse "-4.42330604244772E-305" printfn $"Double value from literal: {fromLiteral,29:R}" printfn $"Double value from variable: {fromVariable,28:R}" printfn $"Double value from Parse method: {fromParse,24:R}" -// On 32-bit versions of the .NET Framework, the output is: + +// On 32-bit versions of .NET, the output is: + // Double value from literal: -4.42330604244772E-305 // Double value from variable: -4.42330604244772E-305 // Double value from Parse method: -4.42330604244772E-305 // -// On other versions of the .NET Framework, the output is: +// On other versions of .NET, the output is: + // Double value from literal: -4.4233060424477198E-305 // Double value from variable: -4.4233060424477198E-305 // Double value from Parse method: -4.42330604244772E-305 -// \ No newline at end of file + +// diff --git a/snippets/fsharp/System/String/IndexOf/ignorable21.fs b/snippets/fsharp/System/String/IndexOf/ignorable21.fs index e294c897051..634e3ed78b3 100644 --- a/snippets/fsharp/System/String/IndexOf/ignorable21.fs +++ b/snippets/fsharp/System/String/IndexOf/ignorable21.fs @@ -15,12 +15,13 @@ printfn $"""{s2.IndexOf "\u00ADn"}""" printfn $"""{s1.IndexOf "\u00ADm"}""" printfn $"""{s2.IndexOf "\u00ADm"}""" -// The example displays the following output -// if run under the .NET Framework 4 or later: +// The example displays the following output: + // 0 // 0 // 1 // 1 // 4 // 3 + // diff --git a/snippets/fsharp/System/TimeSpan/Parse/parsefailure1.fs b/snippets/fsharp/System/TimeSpan/Parse/parsefailure1.fs index 54ff371765d..f8857ccec90 100644 --- a/snippets/fsharp/System/TimeSpan/Parse/parsefailure1.fs +++ b/snippets/fsharp/System/TimeSpan/Parse/parsefailure1.fs @@ -7,17 +7,14 @@ let values = [| "000000006"; "12.12:12:12.12345678" |] for value in values do try let interval = TimeSpan.Parse value - printfn $"{value} --> {interval}" + printfn $"{value} --> {interval}" with | :? FormatException -> printfn $"{value}: Bad Format" | :? OverflowException -> printfn $"{value}: Overflow" -// Output from .NET Framework 3.5 and earlier versions: -// 000000006 --> 6.00:00:00 -// 12.12:12:12.12345678: Bad Format -// Output from .NET Framework 4 and later versions or .NET Core: +// Output: // 000000006: Overflow // 12.12:12:12.12345678: Overflow -// \ No newline at end of file +// diff --git a/snippets/fsharp/System/Type/Assembly/type_assembly.fs b/snippets/fsharp/System/Type/Assembly/type_assembly.fs index 0c256d12309..9c330bbcdf7 100644 --- a/snippets/fsharp/System/Type/Assembly/type_assembly.fs +++ b/snippets/fsharp/System/Type/Assembly/type_assembly.fs @@ -8,9 +8,12 @@ printfn $"Assembly full name:\n {objType.Assembly.FullName}." // Print the assembly qualified name. printfn $"Assembly qualified name:\n {objType.AssemblyQualifiedName}." -// The example displays the following output if run under the .NET Framework 4.5: + +// The example displays output similar to the following: +// // Assembly full name: -// mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089. +// System.Private.CoreLib, Version = 10.0.0.0, Culture = neutral, PublicKeyToken = 7cec85d7bea7798e. // Assembly qualified name: -// System.Array, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089. -// \ No newline at end of file +// System.Array, System.Private.CoreLib, Version = 10.0.0.0, Culture = neutral, PublicKeyToken = 7cec85d7bea779 + +// diff --git a/snippets/visualbasic/Microsoft.VisualBasic.Devices/ServerComputer/FileSystem/Class1.vb b/snippets/visualbasic/Microsoft.VisualBasic.Devices/ServerComputer/FileSystem/Class1.vb deleted file mode 100644 index 95188e6484c..00000000000 --- a/snippets/visualbasic/Microsoft.VisualBasic.Devices/ServerComputer/FileSystem/Class1.vb +++ /dev/null @@ -1,1102 +0,0 @@ - -Option Explicit On -Option Strict On - -' -Imports System.IO -' - -Imports System.Drawing -Imports System.Windows.Forms -Imports Microsoft.VisualBasic.FileIO - -Class Class00ad6fbd924e4a49af32d505fe69ea32 - ' 00ad6fbd-924e-4a49-af32-d505fe69ea32 - ' My.Computer.FileSystem.RenameFile Method - - Public Sub Method1() - ' - My.Computer.FileSystem.RenameFile("C:\Test.txt", "SecondTest.txt") - ' - End Sub - -End Class - -Class Class0351a2ca24d843b5bb399b99e6401cff - ' 0351a2ca-24d8-43b5-bb39-9b99e6401cff - ' How to: Create a Directory in Visual Basic - - Public Sub Method2() - ' - My.Computer.FileSystem.CreateDirectory( - "C:\Documents and Settings\All Users\Documents\NewDirectory") - ' - End Sub - -End Class - -Class Class07637b38bd9949b18cc0dc37cdb14dba - ' 07637b38-bd99-49b1-8cc0-dc37cdb14dba - ' My.Computer.FileSystem.DeleteFile Method - - Public Sub Method3() - ' - My.Computer.FileSystem.DeleteFile("C:\test.txt") - ' - End Sub - - Public Sub Method4() - ' - My.Computer.FileSystem.DeleteFile( - "C:\test.txt", - FileIO.UIOption.AllDialogs, - FileIO.RecycleOption.SendToRecycleBin, - FileIO.UICancelOption.ThrowException) - ' - End Sub - - Public Sub Method5() - ' - My.Computer.FileSystem.DeleteFile( - "C:\test.txt", - FileIO.UIOption.OnlyErrorDialogs, - FileIO.RecycleOption.SendToRecycleBin, - FileIO.UICancelOption.ThrowException) - ' - End Sub - -End Class - -Class Class0c50a18fc24e4266a95276bce924ad3e - ' 0c50a18f-c24e-4266-a952-76bce924ad3e - ' How to: Determine How Many Files Are in a Directory in Visual Basic - - Public Sub Method6() - ' - Dim counter = My.Computer.FileSystem.GetFiles("C:\TestDir") - MsgBox("number of files is " & CStr(counter.Count)) - ' - End Sub - - Public Sub Method7() - ' - Dim counter = My.Computer.FileSystem.GetFiles("C:\TestDir") - ' - End Sub - - Public Sub Method8() - Dim counter = My.Computer.FileSystem.GetFiles("C:\TestDir") - ' - MsgBox("number of files is " & CStr(counter.Count)) - ' - End Sub - -End Class - -Class Class0ea7e0c82cb24bf5a00d7b6e3c08a3bc - ' 0ea7e0c8-2cb2-4bf5-a00d-7b6e3c08a3bc - ' How to: Rename a File in Visual Basic - - Public Sub Method9() - ' - ' Change "c:\test.txt" to the path and filename for the file that - ' you want to rename. - My.Computer.FileSystem.RenameFile("C:\Test.txt", "SecondTest.txt") - ' - End Sub - -End Class - -Class Class0f26d1efc0a044458eb09b7d0490411c - ' 0f26d1ef-c0a0-4445-8eb0-9b7d0490411c - ' How to: Move a Directory in Visual Basic - - Public Sub Method10() - ' - My.Computer.FileSystem.MoveDirectory("C:\Dir1", "C:\Dir2") - ' - End Sub - - Public Sub Method11() - ' - My.Computer.FileSystem.MoveDirectory("C:\Dir1", "C:\Dir2", True) - ' - End Sub - -End Class - -Class Class10d9a542698c4150ada9033527605b7f - ' 10d9a542-698c-4150-ada9-033527605b7f - ' My.Computer.FileSystem.GetTempFileName Method - - Public Sub Method12() - ' - MsgBox("The file is located at " & - My.Computer.FileSystem.GetTempFileName) - ' - End Sub - -End Class - -Class Class14700cb39d2946e2af8d61970d7e251b - ' 14700cb3-9d29-46e2-af8d-61970d7e251b - ' My.Computer.FileSystem.RenameDirectory Method - - Public Sub Method13() - ' - My.Computer.FileSystem.RenameDirectory("C:MyDocuments\Test", "SecondTest") - ' - End Sub - -End Class - -Class Class1c726124781d49769baaed46814ff3fe - ' 1c726124-781d-4976-9baa-ed46814ff3fe - ' How to: Write Text to Files in MyDocuments (Visual Basic) - - Public Sub Method14() - Dim filepath As String = "filepath" - ' - My.Computer.FileSystem.WriteAllText(filePath, "some text", True) - ' - End Sub - -End Class - -Class Class26560d017dda44578e9521db23d71aea - ' 26560d01-7dda-4457-8e95-21db23d71aea - ' How to: Retrieve the Contents of the MyDocuments Folder in Visual Basic - - Public Sub Method15() - ' - Dim path As String - Dim patients As String - path = My.Computer.FileSystem.SpecialDirectories.MyDocuments & "\" & "Patients.txt" - patients = My.Computer.FileSystem.ReadAllText(path) - ' - End Sub - -End Class - -Class Class2a370bd710ba4219afc44519d031eb6c - ' 2a370bd7-10ba-4219-afc4-4519d031eb6c - ' How to: Copy a Directory to Another Directory in Visual Basic - - Public Sub Method16() - ' - My.Computer.FileSystem.CopyDirectory("C:\TestDirectory1", "C:\TestDirectory2", True) - ' - End Sub - -End Class - -Class Class2c1688d2a60c4e689a1a4006917b28e1 - ' 2c1688d2-a60c-4e68-9a1a-4006917b28e1 - ' My.Computer.FileSystem.CreateDirectory Method - - Public Sub Method17() - ' - My.Computer.FileSystem.CreateDirectory( - "C:\Documents and Settings\All Users\Documents\NewDirectory") - ' - End Sub - -End Class - -Class Class2ebefb41a88946a594068688329288c3 - ' 2ebefb41-a889-46a5-9406-8688329288c3 - ' My.Computer.FileSystem.CurrentDirectory Property - - Public Sub Method18() - ' - MsgBox(My.Computer.FileSystem.CurrentDirectory) - ' - End Sub - - Public Sub Method19() - ' - My.Computer.FileSystem.CurrentDirectory = "C:\TestDirectory" - ' - End Sub - -End Class - -Class Class3c2a7073f7b540c0b3973c9f3d43caeb - ' 3c2a7073-f7b5-40c0-b397-3c9f3d43caeb - ' How to: Determine a Drive's Physical Free Space in Visual Basic - - Public Sub Method20() - ' - Dim cdrive As System.IO.DriveInfo - cdrive = My.Computer.FileSystem.GetDriveInfo("C:\") - MsgBox("Total free space: " & CStr(cdrive.TotalFreeSpace)) - ' - End Sub - -End Class - -Class Class3d201ebc54994ee286d0c2d8f023701d - ' 3d201ebc-5499-4ee2-86d0-c2d8f023701d - ' My.Computer.FileSystem.GetName Method - - Public Sub Method21() - ' - MsgBox("The filename is: " & - My.Computer.FileSystem.GetName("C:\testdirectory\testfile")) - ' - End Sub - -End Class - -Class Class4b7217693e454be7b7feb08dc4141b44 - ' 4b721769-3e45-4be7-b7fe-b08dc4141b44 - ' How to: Delete a File in Visual Basic - - Public Sub Method22() - ' - My.Computer.FileSystem.DeleteFile("C:\test.txt") - ' - End Sub - -End Class - -Class Class4c14545654534bdaaab5578dc8bee59a - ' 4c145456-5453-4bda-aab5-578dc8bee59a - ' My.Computer.FileSystem Object - - Public Sub Method23() - ' - Dim logInfo As System.IO.DirectoryInfo - If My.Computer.FileSystem.DirectoryExists("C:\backup\logs") Then - logInfo = My.Computer.FileSystem.GetDirectoryInfo( - "C:\backup\logs") - End If - ' - End Sub - -End Class - -Class Class53a7457b581541adb37d28537c1fb77a - ' 53a7457b-5815-41ad-b37d-28537c1fb77a - ' How to: Move a File in Visual Basic - - Public Sub Method24() - ' - My.Computer.FileSystem.MoveFile("C:\TestDir1\test.txt", - "C:\TestDir2\test.txt") - ' - End Sub - - Public Sub Method25() - ' - My.Computer.FileSystem.MoveFile("C:\TestDir1\test.txt", - "C:\TestDir2\nexttest.txt", - FileIO.UIOption.AllDialogs, - FileIO.UICancelOption.ThrowException) - ' - End Sub - -End Class - -Class Class585f14af16694efd83c55e576a487d5d - ' 585f14af-1669-4efd-83c5-5e576a487d5d - ' My.Computer.FileSystem.SpecialDirectories.MyMusic Property - - Public Sub Method26() - ' - MsgBox(My.Computer.FileSystem.SpecialDirectories.MyMusic) - ' - End Sub - -End Class - -Class Class59fae125de5b4c96883c209f4a55112c - ' 59fae125-de5b-4c96-883c-209f4a55112c - ' How to: Write to a Binary File in Visual Basic - - Public Sub Method27() - Dim customerQuery As Byte() = {0} - ' - Dim CustomerData As Byte() = (From c In customerQuery).ToArray() - - My.Computer.FileSystem.WriteAllBytes( - "C:\MyDocuments\CustomerData", CustomerData, True) - ' - End Sub - -End Class - - - -Class Class68d88e077f2748deb7438d7baf5b590e - ' 68d88e07-7f27-48de-b743-8d7baf5b590e - ' My.Computer.FileSystem.SpecialDirectories.Temp Property - - Public Sub Method31() - ' - MsgBox(My.Computer.FileSystem.SpecialDirectories.Temp) - ' - End Sub - -End Class - -Class Class6c8ba7e8dd37485392bf762b67c98160 - ' 6c8ba7e8-dd37-4853-92bf-762b67c98160 - ' How to: Get the Collection of Files in a Directory in Visual Basic - - Public Sub Method32() - Dim listBox1 As New System.Windows.Forms.ListBox - ' - For Each foundFile As String In My.Computer.FileSystem.GetFiles( - My.Computer.FileSystem.SpecialDirectories.MyDocuments) - - listBox1.Items.Add(foundFile) - Next - ' - End Sub - -End Class - -Class Class76a7ee5aed55479880737592aee2ff47 - ' 76a7ee5a-ed55-4798-8073-7592aee2ff47 - ' My.Computer.FileSystem.ReadAllBytes Method - - Public Sub Method33() - ' - My.Computer.FileSystem.ReadAllBytes( - "C:/Documents and Settings/selfportrait.jpg") - ' - End Sub - -End Class - -Class Class780c7afca03c4b01865a510fe331b1cc - ' 780c7afc-a03c-4b01-865a-510fe331b1cc - ' How to: Rename a Directory in Visual Basic - - Public Sub Method34() - ' - My.Computer.FileSystem.RenameDirectory("C:MyDocuments\Test", - "SecondTest") - ' - End Sub - -End Class - -Class Class7d2109ebf98a4389b43d30f384aaa7d5 - ' 7d2109eb-f98a-4389-b43d-30f384aaa7d5 - ' Walkthrough: Manipulating Files Using .NET Framework Methods - - - Public Sub Method36() - ' - Dim fw As StreamWriter - ' - fw = New StreamWriter("C:\MyDiary.txt", True) - End Sub - - Public Sub Method37() - Dim fw As StreamWriter - Dim entry As New System.Windows.Forms.TextBox - fw = New StreamWriter("C:\MyDiary.txt", True) - ' - Dim ReadString As String - Try - 'Pass the file path and name to the StreamWriter constructor. - 'Indicate that Append is True, so file will not be overwritten. - fw = New StreamWriter("C:\MyDiary.txt", True) - ReadString = Entry.Text - fw.WriteLine(ReadString) - Finally - 'Close the file. - fw.Close() - End Try - ' - End Sub - - Public Sub Method38() - Dim fw As StreamWriter - Dim entry As New System.Windows.Forms.TextBox - fw = New StreamWriter("C:\MyDiary.txt", True) - ' - If (Entry.Text = "" Or Entry.Text = "Please enter something.") Then - Entry.Text = "Please enter something." - Return - End If - ' - End Sub - - Public Sub Method39() - Dim fw As StreamWriter - Dim entry As New System.Windows.Forms.TextBox - fw = New StreamWriter("C:\MyDiary.txt", True) - ' - Dim Today As DateTime - Today = Now - fw.Write(CStr(Today)) - fw.Write(ControlChars.CrLf) - ' - End Sub - - Public Sub Method40() - Dim fw As StreamWriter - Dim entry As New System.Windows.Forms.TextBox - fw = New StreamWriter("C:\MyDiary.txt", True) - ' - Entry.Text = "" - ' - End Sub - - Public Sub Method41() - Dim pickentries As New System.Windows.Forms.ListBox - ' - Dim fr As StreamReader = Nothing - Dim FileString As String - FileString = "" - Try - fr = New System.IO.StreamReader("C:\MyDiary.txt") - PickEntries.Items.Clear() - PickEntries.Enabled = True - Do - FileString = fr.ReadLine - If IsDate(FileString) Then - PickEntries.Items.Add(FileString) - End If - Loop Until (FileString Is Nothing) - Finally - If fr IsNot Nothing Then - fr.Close() - End If - End Try - PickEntries.Enabled = True - ' - End Sub - - Public Sub Method42() - Dim pickentries As New System.Windows.Forms.ComboBox - Dim displayentry As New System.Windows.Forms.Button - ' - Dim fr As StreamReader - Dim ReadString As String - 'Make sure ReadString begins empty. - ReadString = "" - Dim FileString As String - fr = New StreamReader("C:\MyDiary.txt") - 'If no entry has been selected, show the whole file. - If PickEntries.Enabled = False Or PickEntries.SelectedText Is Nothing Then - Do - 'Read a line from the file into FileString. - FileString = fr.ReadLine - 'add it to ReadString - ReadString = ReadString & ControlChars.CrLf & FileString - Loop Until (FileString = Nothing) - Else - 'An entry has been selected, find the line that matches. - Do - - FileString = fr.ReadLine - Loop Until FileString = CStr(PickEntries.SelectedItem) - FileString = CStr(PickEntries.SelectedItem) & ControlChars.CrLf - ReadString = FileString & fr.ReadLine - - 'Read from the file until EOF or another Date is found. - Do Until ((fr.Peek < 0) Or (IsDate(fr.ReadLine))) - ReadString = ReadString & fr.ReadLine - Loop - End If - fr.Close() - DisplayEntry.Visible = True - DisplayEntry.Text = ReadString - ' - End Sub - - Public Sub Method43() - Dim deleteentry As New System.Windows.Forms.Button - - ' - DeleteEntry.enabled = True - ' - End Sub - - Public Sub Method44() - Dim displayentry As New System.Windows.Forms.TextBox - Dim pickentries As New System.Windows.Forms.ComboBox - Dim deleteentry As New System.Windows.Forms.TextBox - - ' - Dim fr As StreamReader - Dim ReadString As String - Dim WriteString As String - Dim ConfirmDelete As MsgBoxResult - fr = New StreamReader("C:\MyDiary.txt") - ReadString = fr.ReadLine - ' Read through the textfile - Do Until (fr.Peek < 0) - ReadString = ReadString & vbCrLf & fr.ReadLine - Loop - WriteString = Replace(ReadString, DisplayEntry.Text, "") - fr.Close() - ' Check to make sure the user wishes to delete the entry - ConfirmDelete = MsgBox("Do you really wish to delete this entry?", - MsgBoxStyle.OKCancel) - If ConfirmDelete = MsgBoxResult.OK Then - File.Delete("C:\MyDiary.txt") - Dim fw As StreamWriter = File.CreateText("C:\MyDiary.txt") - fw.WriteLine(WriteString) - fw.Close() - ' Reset controls on the form - DisplayEntry.Text = "" - PickEntries.Text = "" - PickEntries.Items.Clear() - PickEntries.Enabled = False - DeleteEntry.Enabled = False - End If - ' - End Sub - - Public Sub Method45() - Dim editentry As New System.Windows.Forms.Button - ' - EditEntry.Enabled = True - ' - End Sub - - Public Sub Method46() - Dim entry As New System.Windows.Forms.TextBox - Dim displayentry As New System.Windows.Forms.TextBox - Dim submitedit As New System.Windows.Forms.Button - ' - Entry.Text = DisplayEntry.Text - SubmitEdit.Enabled = True - ' - End Sub - - Public Sub Method47() - Dim entry As New System.Windows.Forms.TextBox - Dim displayentry As New System.Windows.Forms.TextBox - Dim editentry As New System.Windows.Forms.Button - Dim submitedit As New System.Windows.Forms.Button - ' - Dim fr As StreamReader - Dim ReadString As String - Dim WriteString As String - If Entry.Text = "" Then - MsgBox("Use Delete to Delete an Entry") - Return - End If - fr = New StreamReader("C:\MyDiary.txt") - ReadString = fr.ReadLine - Do Until (fr.Peek < 0) - ReadString = ReadString & vbCrLf & fr.ReadLine - Loop - WriteString = Replace(ReadString, DisplayEntry.Text, Entry.Text) - fr.Close() - File.Delete("C:\MyDiary.txt") - Dim fw As StreamWriter = File.CreateText("C:\MyDiary.txt") - fw.WriteLine(WriteString) - fw.Close() - DisplayEntry.Text = Entry.Text - Entry.Text = "" - EditEntry.Enabled = False - SubmitEdit.Enabled = False - ' - End Sub - -End Class - -Class Classab01af4109ca4206b81d876379a18e3b - ' ab01af41-09ca-4206-b81d-876379a18e3b - ' My.Computer.FileSystem.SpecialDirectories.CurrentUserApplicationData Property - - Public Sub Method48() - ' - MsgBox(My.Computer.FileSystem.SpecialDirectories.CurrentUserApplicationData) - ' - End Sub - -End Class - -Class Classaedb6fd5dca3415388b601b9796329c3 - ' aedb6fd5-dca3-4153-88b6-01b9796329c3 - ' My.Computer.FileSystem.CopyDirectory Method - - Public Sub Method49() - ' - My.Computer.FileSystem.CopyDirectory("C:\TestDirectory1", "C:\TestDirectory2", True) - ' - End Sub - -End Class - -Class Classb1a24dc1eac84e228ffacc3bacbaf826 - ' b1a24dc1-eac8-4e22-8ffa-cc3bacbaf826 - ' My.Computer.FileSystem.WriteAllBytes Method - - Public Sub Method50() - Dim customerdata As Byte() = {0} - ' - My.Computer.FileSystem.WriteAllBytes( - "C:\MyDocuments\CustomerData", CustomerData, True) - ' - End Sub - -End Class - -Class Classb2fdda86e66642c297069527e9fa68ff - ' b2fdda86-e666-42c2-9706-9527e9fa68ff - ' How to: Create a Copy of a File in the Same Directory in Visual Basic - - Public Sub Method51() - ' - My.Computer.FileSystem.CopyFile("C:\TestFolder\test.txt", - "C:\TestFolder\test2.txt", Microsoft.VisualBasic.FileIO.UIOption.OnlyErrorDialogs, FileIO.UICancelOption.DoNothing) - ' - End Sub - - Public Sub Method52() - ' - My.Computer.FileSystem.CopyFile("C:\TestFolder\test.txt", - "C:\TestFolder\test2.txt", True) - ' - End Sub - -End Class - -Class Classb55a2a7967e84a05b88bc2dee1fc5b2f - ' b55a2a79-67e8-4a05-b88b-c2dee1fc5b2f - ' My.Computer.FileSystem.SpecialDirectories.MyDocuments Property - - Public Sub Method53() - ' - MsgBox(My.Computer.FileSystem.SpecialDirectories.MyDocuments) - ' - End Sub - -End Class - -Class Classc1bd99c98160456ab5ab60a49139b923 - ' c1bd99c9-8160-456a-b5ab-60a49139b923 - ' How to: Parse File Paths in Visual Basic - - Public Sub Method54() - ' - Dim testFile As System.IO.FileInfo - testFile = My.Computer.FileSystem.GetFileInfo("C:\TestFolder1\test1.txt") - Dim folderPath As String = testFile.DirectoryName - MsgBox(folderPath) - Dim fileName As String = testFile.Name - MsgBox(fileName) - ' - - ' - Dim fullPath As String - fullPath = My.Computer.FileSystem.CombinePath(folderPath, fileName) - MsgBox(fullPath) - ' - End Sub - -End Class - -Class Classc8038bac8e59467d85d9a5d5e6367737 - ' c8038bac-8e59-467d-85d9-a5d5e6367737 - ' My.Computer.FileSystem.DeleteDirectory Method - - Public Sub Method56() - ' - My.Computer.FileSystem.DeleteDirectory( - "C:\OldDirectory", - FileIO.DeleteDirectoryOption.ThrowIfDirectoryNonEmpty) - ' - End Sub - - Public Sub Method57() - ' - My.Computer.FileSystem.DeleteDirectory( - "C:\OldDirectory", - FileIO.DeleteDirectoryOption.DeleteAllContents) - ' - End Sub - - Public Sub Method58() - ' - My.Computer.FileSystem.DeleteDirectory( - "C:\OldDirectory", - FileIO.UIOption.AllDialogs, - FileIO.RecycleOption.DeletePermanently, - FileIO.UICancelOption.ThrowException) - ' - End Sub - - Public Sub Method59() - ' - My.Computer.FileSystem.DeleteDirectory( - "C:\OldDirectory", - FileIO.UIOption.AllDialogs, - FileIO.RecycleOption.SendToRecycleBin, - FileIO.UICancelOption.ThrowException) - ' - End Sub - -End Class - -Class Classc8f1380032514f11b47a5f0489989ba7 - ' c8f13800-3251-4f11-b47a-5f0489989ba7 - ' My.Computer.FileSystem.SpecialDirectories.Desktop Property - - Public Sub Method60() - ' - MsgBox(My.Computer.FileSystem.SpecialDirectories.Desktop) - ' - End Sub - -End Class - -Class Classc98e98f7fc4e4f7abe917c532c858df0 - ' c98e98f7-fc4e-4f7a-be91-7c532c858df0 - ' My.Computer.FileSystem.SpecialDirectories.Programs Property - - Public Sub Method61() - ' - MsgBox(My.Computer.FileSystem.SpecialDirectories.Programs) - ' - End Sub - -End Class - -Class Classcae775659f784e468e42eb2f9f8e1ffd - Inherits System.Windows.Forms.Form - ' cae77565-9f78-4e46-8e42-eb2f9f8e1ffd - ' Walkthrough: Manipulating Files and Directories in Visual Basic - Dim DirectoryTextBox As New System.Windows.Forms.TextBox - Dim FilePickComboBox As New System.Windows.Forms.ComboBox - Dim LastAccessCheckBox As New System.Windows.Forms.CheckBox - Dim SaveCheckBox As New System.Windows.Forms.CheckBox - Dim FileLengthCheckBox As New System.Windows.Forms.CheckBox - - ' Dim strFirstline As String - 'Dim firstline As String - 'Dim lastaccess As Date - 'Dim foundFile As New System.IO.FileInfo("test.txt") - 'Dim length As Long - - Private Sub Form1_Load() Handles Me.Load - ' - DirectoryTextBox.Text = My.Computer.FileSystem.CurrentDirectory - ' - End Sub - - Public Sub btnSubmit_Click() - - Dim fileList As System.Collections.ObjectModel.ReadOnlyCollection(Of String) - - Dim errorMessage = "" - - ' - ' newPath holds the path the user has entered. - Dim newPath = DirectoryTextBox.Text - ' Change the location to newPath. - My.Computer.FileSystem.CurrentDirectory = newPath - ' - - - ' - Try - ' - - My.Computer.FileSystem.CurrentDirectory = newPath - - ' - ' This checks to make sure the path is not blank. - Catch ex As Exception When newPath = "" - ErrorMessage = "You must enter a path." - ' This catches errors caused by a path that is not valid. - Catch - ErrorMessage = "You must enter a valid path. If trying " & - "to access a different drive, remember to include the drive " & - "letter." - Finally - ' Display the error message only if one exists. - If errorMessage <> Nothing Then - MsgBox(errorMessage) - End If - End Try - ' - - ' - fileList = My.Computer.FileSystem.GetFiles( - My.Computer.FileSystem.CurrentDirectory, - FileIO.SearchOption.SearchTopLevelOnly, "*.txt") - For Each foundFile In fileList - FilePickComboBox.Items.Add(foundFile) - Next - ' - End Sub - - Public Sub btnExamine_Click() - ' - Dim thisFile = - My.Computer.FileSystem.GetFileInfo(CStr(FilePickComboBox.SelectedItem)) - ' - - ' - Dim stringlength = "The file's length, in bytes, is: " - Dim stringLastAccess = "The file was last accessed on: " - Dim lastAccess As Date - Dim length As Long - Dim firstLine = "" - Dim finalString = "" - - If FilePickComboBox.SelectedItem Is Nothing Then - MsgBox("You must select a file to examine.") - Exit Sub - End If - - Dim newName = CStr(FilePickComboBox.SelectedItem) - ' - - ' - ' Check last access time. - If LastAccessCheckBox.Checked = True Then - lastAccess = thisFile.LastAccessTime - End If - ' - ' - ' Add to the message box. - finalString = finalString & stringLastAccess & lastAccess & "." & - vbCrLf - ' - - ' - ' Check length. - If FileLengthCheckBox.Checked = True Then - length = thisFile.Length - End If - ' - ' - ' Add to the message box. - finalString = finalString & stringlength & CStr(Length) & "." & - vbCrLf - ' - - ' - ' Add to the message box. - finalString &= firstLine & vbCrLf - ' - - ' - ' Check to see whether results should be saved. - If SaveCheckBox.Checked = True AndAlso finalString <> "" Then - My.Computer.FileSystem.WriteAllText("log.txt", finalString, True) - End If - ' - End Sub - -End Class - -Class Classcfba872bf268400f983a2e4525845874 - ' cfba872b-f268-400f-983a-2e4525845874 - ' My.Computer.FileSystem.SpecialDirectories.MyPictures Property - - Public Sub Method77() - ' - MsgBox(My.Computer.FileSystem.SpecialDirectories.MyPictures) - ' - End Sub - -End Class - -Class Classd2b1269e24b642e09414ae708db282d8 - ' d2b1269e-24b6-42e0-9414-ae708db282d8 - ' How to: Read From a Binary File in Visual Basic - - Public Sub Method78() - Dim PictureBox1 As New PictureBox - ' - Dim bytes = My.Computer.FileSystem.ReadAllBytes( - "C:/Documents and Settings/selfportrait.jpg") - PictureBox1.Image = Image.FromStream(New IO.MemoryStream(bytes)) - ' - End Sub - - ' - ' This method does not trap for exceptions. If an exception is - ' encountered opening the file to be copied or writing to the - ' destination location, then the exception will be thrown to - ' the requestor. - Public Sub CopyBinaryFile(ByVal path As String, - ByVal copyPath As String, - ByVal bufferSize As Integer, - ByVal overwrite As Boolean) - - Dim inputFile = IO.File.Open(path, IO.FileMode.Open) - - If overwrite AndAlso My.Computer.FileSystem.FileExists(copyPath) Then - My.Computer.FileSystem.DeleteFile(copyPath) - End If - - ' Adjust array length for VB array declaration. - Dim bytes = New Byte(bufferSize - 1) {} - - While inputFile.Read(bytes, 0, bufferSize) > 0 - My.Computer.FileSystem.WriteAllBytes(copyPath, bytes, True) - End While - - inputFile.Close() - End Sub - ' - -End Class - -Class Classd5b61ecef32746fba82ad6b102dbc0ca - ' d5b61ece-f327-46fb-a82a-d6b102dbc0ca - ' My.Computer.FileSystem.SpecialDirectories.AllUsersApplicationData Property - - Public Sub Method79() - ' - MsgBox( - My.Computer.FileSystem.SpecialDirectories.AllUsersApplicationData) - ' - End Sub - -End Class - -Class Classd5f375c3094b4011843817a31bc6df2b - ' d5f375c3-094b-4011-8438-17a31bc6df2b - ' My.Computer.FileSystem.SpecialDirectories Object - - Public Sub Method80() - ' - Dim filePath As String - filePath = My.Computer.FileSystem.SpecialDirectories.Desktop - MsgBox(filePath) - ' - End Sub - -End Class - -Class Classe03f46b0dfbf450491fe8e46b0e7cb1d - ' e03f46b0-dfbf-4504-91fe-8e46b0e7cb1d - ' My.Computer.FileSystem.MoveDirectory Method - - Public Sub Method81() - ' - My.Computer.FileSystem.MoveDirectory("C:\Directory1", "C:\Directory2") - ' - End Sub - - Public Sub Method82() - ' - My.Computer.FileSystem.MoveDirectory("C:\Directory1", "C:\Directory2", - True) - ' - End Sub - -End Class - -Class Classe80452a8e9b74532a20e97edb859d121 - ' e80452a8-e9b7-4532-a20e-97edb859d121 - ' How to: Delete a Directory in Visual Basic - - Public Sub Method83() - ' - My.Computer.FileSystem.DeleteDirectory("C:\OldDirectory", - FileIO.DeleteDirectoryOption.ThrowIfDirectoryNonEmpty) - ' - End Sub - - Public Sub Method84() - ' - My.Computer.FileSystem.DeleteDirectory("C:\OldDirectory", - FileIO.DeleteDirectoryOption.DeleteAllContents) - ' - End Sub - - Public Sub Method85() - ' - My.Computer.FileSystem.DeleteDirectory("C:\OldDirectory", FileIO.UIOption.AllDialogs, FileIO.RecycleOption.SendToRecycleBin) - ' - End Sub - -End Class - -Class Classf13ecad9b95f49239f05c061a1617756 - ' f13ecad9-b95f-4923-9f05-c061a1617756 - ' My.Computer.FileSystem.MoveFile Method - - Public Sub Method86() - ' - My.Computer.FileSystem.MoveFile("C:\TestDir1\test.txt", "C:\TestDir2\test.txt") - ' - End Sub - - Public Sub Method87() - ' - My.Computer.FileSystem.MoveFile("C:\TestDir1\test.txt", "C:\TestDir2\test2.txt") - ' - End Sub - -End Class - -Class Classf205d2adbbe54d558a40acda21aa82dd - ' f205d2ad-bbe5-4d55-8a40-acda21aa82dd - ' How to: Copy Files with a Specific Pattern to a Directory in Visual Basic - - Public Sub Method88() - Dim foundfile As String = "x" - - ' - My.Computer.FileSystem.CopyFile(foundFile, "C:\testdirectory\" & My.Computer.FileSystem.GetName(foundFile)) - ' - End Sub - - Public Sub Method89() - Dim i As Integer - For i = 1 To 5 - ' - Next - ' - End Sub - -End Class - -Class Class7bb0d83e875a4b158935bdc24e71ef98 - ' 7bb0d83e-875a-4b15-8935-bdc24e71ef98 - ' My.Computer.FileSystem.SpecialDirectories.ProgramFiles Property - - Public Sub Method90() - ' - MsgBox(My.Computer.FileSystem.SpecialDirectories.ProgramFiles) - ' - End Sub - -End Class - -Class Classe02587a6e85494d7f9392beae2c7f3903 - '02587a6e-8549-4d7f-9392-beae2c7f3903 - ' My.Computer.FileSystem.CopyDirectory Method - Public Sub Method94() - ' - My.Computer.FileSystem.CopyDirectory("C:\TestDirectory1", "C:\TestDirectory2") - ' - End Sub -End Class - -Class Classe664cd9b1a9174Ffc96ed789c60582205 - ' 664cd9b1-a917-4ffc-96ed-789c60582205 - ' My.Computer.FileSystem.CopyDirectory Method - Public Sub Method92() - ' - My.Computer.FileSystem.CopyDirectory("C:\TestDirectory1", "C:\TestDirectory2", UIOption.AllDialogs) - ' - End Sub -End Class - -Class Classe9df56b2b8eb34f9ba184c2bb529eeaa7 - ' 9df56b2b-8eb3-4f9b-a184-c2bb529eeaa7 - ' My.Computer.FileSystem.CopyDirectory Method - Public Sub Method93() - ' - My.Computer.FileSystem.CopyDirectory("C:\TestDirectory1", "C:\TestDirectory2", UIOption.AllDialogs, UICancelOption.DoNothing) - ' - End Sub -End Class diff --git a/snippets/visualbasic/System.CodeDom.Compiler/CodeDomProvider/CreateProvider/source.vb b/snippets/visualbasic/System.CodeDom.Compiler/CodeDomProvider/CreateProvider/source.vb index ecce48f6222..91da2dd0421 100644 --- a/snippets/visualbasic/System.CodeDom.Compiler/CodeDomProvider/CreateProvider/source.vb +++ b/snippets/visualbasic/System.CodeDom.Compiler/CodeDomProvider/CreateProvider/source.vb @@ -1,10 +1,8 @@ ' System.CodeDom.Compiler.CompilerInfo -' -' Requires .NET Framework version 2.0 or higher. ' ' The following example displays compiler configuration settings. ' Command-line arguments are used to specify a compiler language, -' file extension, or provider type. For the given input, the +' file extension, or provider type. For the given input, the ' example determines the corresponding code compiler settings. ' ' @@ -39,16 +37,16 @@ Namespace CodeDomCompilerInfoSample Dim queryCommand As String = "" Dim queryArg As String = "" Dim iNumArguments As Integer = args.Length - + ' Get input command-line arguments. If iNumArguments > 0 Then queryCommand = args(0).ToUpper(CultureInfo.InvariantCulture) - + If iNumArguments > 1 Then queryArg = args(1) End If End If - + ' Determine which method to call. Console.WriteLine() Select Case queryCommand @@ -62,13 +60,13 @@ Namespace CodeDomCompilerInfoSample ' Display settings for the configured language provider. DisplayCompilerInfoForConfigLanguage(queryArg) Case "ALL" - ' Display compiler information for all configured + ' Display compiler information for all configured ' language providers. DisplayAllCompilerInfo() Case Else - ' There was no command-line argument, or the + ' There was no command-line argument, or the ' command-line argument was not recognized. - ' Display the C#, Visual Basic and JScript + ' Display the C#, Visual Basic and JScript ' compiler information. DisplayCSharpCompilerInfo() DisplayVBCompilerInfo() @@ -76,14 +74,14 @@ Namespace CodeDomCompilerInfoSample End Select End Sub - - + + Shared Sub DisplayCSharpCompilerInfo() - + ' ' Get the provider for Microsoft.CSharp Dim provider = CodeDomProvider.CreateProvider("CSharp") - + ' Display the C# language provider information. Console.WriteLine("CSharp provider is {0}", _ provider.ToString()) @@ -91,17 +89,17 @@ Namespace CodeDomCompilerInfoSample provider.GetHashCode().ToString()) Console.WriteLine(" Default file extension: {0}", _ provider.FileExtension) - + ' Console.WriteLine() End Sub - - + + Shared Sub DisplayVBCompilerInfo() ' ' Get the provider for Microsoft.VisualBasic Dim provider = CodeDomProvider.CreateProvider("VisualBasic") - + ' Display the Visual Basic language provider information. Console.WriteLine("Visual Basic provider is {0}", _ provider.ToString()) @@ -109,20 +107,20 @@ Namespace CodeDomCompilerInfoSample provider.GetHashCode().ToString()) Console.WriteLine(" Default file extension: {0}", _ provider.FileExtension) - + ' Console.WriteLine() End Sub - - + + Shared Sub DisplayJScriptCompilerInfo() ' ' Get the provider for JScript. Dim provider As CodeDomProvider - + Try provider = CodeDomProvider.CreateProvider("js") - + ' Display the JScript language provider information. Console.WriteLine("JScript language provider is {0}", _ provider.ToString()) @@ -138,9 +136,9 @@ Namespace CodeDomCompilerInfoSample ' End Sub - + Shared Sub DisplayCompilerInfoUsingExtension(fileExtension As String) - ' + ' If Not fileExtension.StartsWith(".") Then fileExtension = "." + fileExtension End If @@ -149,24 +147,24 @@ Namespace CodeDomCompilerInfoSample If CodeDomProvider.IsDefinedExtension(fileExtension) Then Dim provider As CodeDomProvider Dim language As String = CodeDomProvider.GetLanguageFromExtension(fileExtension) - + Console.WriteLine("The language ""{0}"" is associated with file extension ""{1}""", _ language, fileExtension) Console.WriteLine() - + ' Check for a corresponding language provider. If CodeDomProvider.IsDefinedLanguage(language) Then provider = CodeDomProvider.CreateProvider(language) - + ' Display information about this language provider. Console.WriteLine("Language provider: {0}", _ provider.ToString()) Console.WriteLine() - + ' Get the compiler settings for this language. Dim langCompilerInfo As CompilerInfo = CodeDomProvider.GetCompilerInfo(language) Dim langCompilerConfig As CompilerParameters = langCompilerInfo.CreateDefaultCompilerParameters() - + Console.WriteLine(" Compiler options: {0}", _ langCompilerConfig.CompilerOptions) Console.WriteLine(" Compiler warning level: {0}", _ @@ -176,18 +174,18 @@ Namespace CodeDomCompilerInfoSample ' Tell the user that the language provider was not found. Console.WriteLine("There is no language provider associated with input file extension ""{0}"".", fileExtension) End If - ' + ' End Sub - - + + Shared Sub DisplayCompilerInfoForLanguage(language As String) - ' + ' Dim provider As CodeDomProvider - - ' Check for a provider corresponding to the input language. + + ' Check for a provider corresponding to the input language. If CodeDomProvider.IsDefinedLanguage(language) Then provider = CodeDomProvider.CreateProvider(language) - + ' Display information about this language provider. Console.WriteLine("Language provider: {0}", _ provider.ToString()) @@ -195,11 +193,11 @@ Namespace CodeDomCompilerInfoSample Console.WriteLine(" Default file extension: {0}", _ provider.FileExtension) Console.WriteLine() - + ' Get the compiler settings for this language. Dim langCompilerInfo As CompilerInfo = CodeDomProvider.GetCompilerInfo(language) Dim langCompilerConfig As CompilerParameters = langCompilerInfo.CreateDefaultCompilerParameters() - + Console.WriteLine(" Compiler options: {0}", _ langCompilerConfig.CompilerOptions) Console.WriteLine(" Compiler warning level: {0}", _ @@ -209,20 +207,20 @@ Namespace CodeDomCompilerInfoSample Console.WriteLine("There is no provider configured for input language ""{0}"".", _ language) End If - ' + ' End Sub - + Shared Sub DisplayCompilerInfoForConfigLanguage(configLanguage As String) ' Dim info As CompilerInfo = CodeDomProvider.GetCompilerInfo(configLanguage) - + ' Check whether there is a provider configured for this language. If info.IsCodeDomProviderTypeValid Then ' Get a provider instance using the configured type information. Dim provider As CodeDomProvider provider = CType(Activator.CreateInstance(info.CodeDomProviderType), CodeDomProvider) - + ' Display information about this language provider. Console.WriteLine("Language provider: {0}", _ provider.ToString()) @@ -230,10 +228,10 @@ Namespace CodeDomCompilerInfoSample Console.WriteLine(" Default file extension: {0}", _ provider.FileExtension) Console.WriteLine() - + ' Get the compiler settings for this language. Dim langCompilerConfig As CompilerParameters = info.CreateDefaultCompilerParameters() - + Console.WriteLine(" Compiler options: {0}", _ langCompilerConfig.CompilerOptions) Console.WriteLine(" Compiler warning level: {0}", _ @@ -244,10 +242,10 @@ Namespace CodeDomCompilerInfoSample End If ' End Sub - - + + Shared Sub DisplayAllCompilerInfo() - ' + ' Dim allCompilerInfo As CompilerInfo() = CodeDomProvider.GetAllCompilerInfo() Dim info As CompilerInfo For Each info In allCompilerInfo @@ -256,27 +254,27 @@ Namespace CodeDomCompilerInfoSample Dim defaultExtension As String Dim provider As CodeDomProvider = info.CreateProvider() - + ' Display information about this configured provider. Console.WriteLine("Language provider: {0}", _ provider.ToString()) Console.WriteLine() - + Console.WriteLine(" Supported file extension(s):") Dim extension As String For Each extension In info.GetExtensions() Console.WriteLine(" {0}", extension) Next extension - + defaultExtension = provider.FileExtension If Not defaultExtension.StartsWith(".") Then defaultExtension = "." + defaultExtension End If - + Console.WriteLine(" Default file extension: {0}", _ defaultExtension) Console.WriteLine() - + Console.WriteLine(" Supported language(s):") Dim language As String For Each language In info.GetLanguages() @@ -286,19 +284,19 @@ Namespace CodeDomCompilerInfoSample Console.WriteLine(" Default language: {0}", _ defaultLanguage) Console.WriteLine() - + ' Get the compiler settings for this provider. Dim langCompilerConfig As CompilerParameters = info.CreateDefaultCompilerParameters() - + Console.WriteLine(" Compiler options: {0}", _ langCompilerConfig.CompilerOptions) Console.WriteLine(" Compiler warning level: {0}", _ langCompilerConfig.WarningLevel) Console.WriteLine() Next info - ' + ' End Sub End Class End Namespace 'CodeDomCompilerInfoSample -' \ No newline at end of file +' diff --git a/snippets/visualbasic/System.ComponentModel/ITypeDescriptorContext/Overview/instancedescriptor.vb b/snippets/visualbasic/System.ComponentModel/ITypeDescriptorContext/Overview/instancedescriptor.vb index 9c55498ecbc..82df0583fdc 100644 --- a/snippets/visualbasic/System.ComponentModel/ITypeDescriptorContext/Overview/instancedescriptor.vb +++ b/snippets/visualbasic/System.ComponentModel/ITypeDescriptorContext/Overview/instancedescriptor.vb @@ -6,11 +6,11 @@ Imports System.Globalization Imports System.Reflection Namespace Microsoft.Samples.InstanceDescriptorSample - ' This sample shows how to support code generation for a custom type + ' This sample shows how to support code generation for a custom type ' of object using a type converter and InstanceDescriptor objects. ' - ' To use this code, copy it to a file and add the file to a project. - ' Then add a component to the project and declare a Triangle field and + ' To use this code, copy it to a file and add the file to a project. + ' Then add a component to the project and declare a Triangle field and ' a public property with accessors for the Triangle field on the component. ' ' The Triangle property will be persisted using code generation. @@ -58,8 +58,8 @@ Namespace Microsoft.Samples.InstanceDescriptorSample ' A TypeConverter for the Triangle object. Note that you can make it internal, ' private, or any scope you want and the designers will still be able to use ' it through the TypeDescriptor object. This type converter provides the - ' capability to convert to an InstanceDescriptor. This object can be used by - ' the .NET Framework to generate source code that creates an instance of a + ' capability to convert to an InstanceDescriptor. This object can be used by + ' .NET to generate source code that creates an instance of a ' Triangle object. Friend Class TriangleConverter @@ -87,9 +87,9 @@ Namespace Microsoft.Samples.InstanceDescriptorSample ' Always call base, even if you can't convert. Return MyBase.ConvertTo(context, culture, value, destinationType) - End Function - End Class - End Class + End Function + End Class + End Class Public Class TestComponent Inherits System.ComponentModel.Component @@ -112,4 +112,4 @@ Namespace Microsoft.Samples.InstanceDescriptorSample End Class End Namespace -' \ No newline at end of file +' diff --git a/snippets/visualbasic/System.Diagnostics/DataReceivedEventArgs/Overview/net_async.vb b/snippets/visualbasic/System.Diagnostics/DataReceivedEventArgs/Overview/net_async.vb index 7cbdbae6f48..30878e5558c 100644 --- a/snippets/visualbasic/System.Diagnostics/DataReceivedEventArgs/Overview/net_async.vb +++ b/snippets/visualbasic/System.Diagnostics/DataReceivedEventArgs/Overview/net_async.vb @@ -1,10 +1,8 @@ ' System.Diagnostics ' -' Requires .NET Framework version 1.2 or higher. -' -' The following example uses the net view command to list the -' available network resources available on a remote computer, +' The following example uses the net view command to list the +' available network resources available on a remote computer, ' and displays the results to the console. Specifying the optional ' error log file redirects error output to that file. @@ -18,7 +16,7 @@ Imports System.Threading Imports System.ComponentModel Namespace ProcessAsyncStreamSamples - + Class ProcessAsyncErrorRedirection ' Define static variables shared by class methods. Private Shared streamError As StreamWriter = Nothing @@ -26,20 +24,20 @@ Namespace ProcessAsyncStreamSamples Private Shared netOutput As StringBuilder = Nothing Private Shared errorRedirect As Boolean = False Private Shared errorsWritten As Boolean = False - + Public Shared Sub RedirectNetCommandStreams() Dim netArguments As String Dim netProcess As Process - + ' Get the input computer name. Console.WriteLine("Enter the computer name for the net view command:") netArguments = Console.ReadLine().ToUpper(CultureInfo.InvariantCulture) If String.IsNullOrEmpty(netArguments) Then - ' Default to the help command if there is + ' Default to the help command if there is ' not an input argument. netArguments = "/?" End If - + ' Check if errors should be redirected to a file. errorsWritten = False Console.WriteLine("Enter a fully qualified path to an error log file") @@ -48,7 +46,7 @@ Namespace ProcessAsyncStreamSamples If Not String.IsNullOrEmpty(netErrorFile) Then errorRedirect = True End If - + ' Note that at this point, netArguments and netErrorFile ' are set with user input. If the user did not specify ' an error file, then errorRedirect is set to false. @@ -56,23 +54,23 @@ Namespace ProcessAsyncStreamSamples ' Initialize the process and its StartInfo properties. netProcess = New Process() netProcess.StartInfo.FileName = "Net.exe" - + ' Build the net command argument list. netProcess.StartInfo.Arguments = String.Format("view {0}", _ netArguments) - + ' Set UseShellExecute to false for redirection. netProcess.StartInfo.UseShellExecute = False - - ' Redirect the standard output of the net command. + + ' Redirect the standard output of the net command. ' Read the stream asynchronously using an event handler. netProcess.StartInfo.RedirectStandardOutput = True AddHandler netProcess.OutputDataReceived, _ AddressOf NetOutputDataHandler netOutput = new StringBuilder() - + If errorRedirect Then - ' Redirect the error output of the net command. + ' Redirect the error output of the net command. netProcess.StartInfo.RedirectStandardError = True AddHandler netProcess.ErrorDataReceived, _ AddressOf NetErrorDataHandler @@ -80,39 +78,39 @@ Namespace ProcessAsyncStreamSamples ' Do not redirect the error output. netProcess.StartInfo.RedirectStandardError = False End If - + Console.WriteLine(ControlChars.Lf + "Starting process: NET {0}", _ netProcess.StartInfo.Arguments) If errorRedirect Then Console.WriteLine("Errors will be written to the file {0}", _ netErrorFile) End If - + ' Start the process. netProcess.Start() - + ' Start the asynchronous read of the standard output stream. netProcess.BeginOutputReadLine() - + If errorRedirect Then ' Start the asynchronous read of the standard ' error stream. netProcess.BeginErrorReadLine() End If - + ' Let the net command run, collecting the output. netProcess.WaitForExit() - + If Not streamError Is Nothing Then ' Close the error file. streamError.Close() - Else + Else ' Set errorsWritten to false if the stream is not ' open. Either there are no errors, or the error ' file could not be opened. errorsWritten = False End If - + If netOutput.Length > 0 Then ' If the process wrote more than just ' white space, write the output to the console. @@ -122,9 +120,9 @@ Namespace ProcessAsyncStreamSamples Console.WriteLine(netOutput) Console.WriteLine() End If - + If errorsWritten Then - ' Signal that the error file had something + ' Signal that the error file had something ' written to it. Dim errorOutput As String() errorOutput = File.ReadAllLines(netErrorFile) @@ -137,15 +135,15 @@ Namespace ProcessAsyncStreamSamples For Each errLine in errorOutput Console.WriteLine(" {0}", errLine) Next - + Console.WriteLine() End If End If - + netProcess.Close() - End Sub - - + End Sub + + Private Shared Sub NetOutputDataHandler(sendingProcess As Object, _ outLine As DataReceivedEventArgs) @@ -154,9 +152,9 @@ Namespace ProcessAsyncStreamSamples ' Add the text to the collected output. netOutput.Append(Environment.NewLine + " " + outLine.Data) End If - End Sub - - + End Sub + + Private Shared Sub NetErrorDataHandler(sendingProcess As Object, _ errLine As DataReceivedEventArgs) @@ -168,7 +166,7 @@ Namespace ProcessAsyncStreamSamples If Not errorsWritten Then If streamError Is Nothing Then ' Open the file. - Try + Try streamError = New StreamWriter(netErrorFile, true) Catch e As Exception Console.WriteLine("Could not open error file!") @@ -188,28 +186,28 @@ Namespace ProcessAsyncStreamSamples errorsWritten = True End If - + If Not streamError Is Nothing Then - + ' Write redirected errors to the file. streamError.WriteLine(errLine.Data) streamError.Flush() End If End If - End Sub - End Class -End Namespace + End Sub + End Class +End Namespace ' Namespace ProcessAsyncStreamSamples - + Class ProcessSampleMain ' The main entry point for the application. Shared Sub Main() Try ProcessAsyncErrorRedirection.RedirectNetCommandStreams() - + Catch e As InvalidOperationException Console.WriteLine("Exception:") Console.WriteLine(e.ToString()) diff --git a/snippets/visualbasic/System.Diagnostics/DataReceivedEventArgs/Overview/nmake_async.vb b/snippets/visualbasic/System.Diagnostics/DataReceivedEventArgs/Overview/nmake_async.vb index ba87fb1f0fe..2b8c0530d62 100644 --- a/snippets/visualbasic/System.Diagnostics/DataReceivedEventArgs/Overview/nmake_async.vb +++ b/snippets/visualbasic/System.Diagnostics/DataReceivedEventArgs/Overview/nmake_async.vb @@ -1,7 +1,4 @@ ' System.Diagnostics -' -' Requires .NET Framework version 1.2 or higher. -' ' ' Define the namespaces used by this sample. @@ -18,12 +15,12 @@ Class ProcessNMakeStreamRedirection Private Shared logMutex As Mutex = New Mutex() Private Shared maxLogLines As Integer = 25 Private Shared currentLogLines As Integer = 0 - - + + Public Shared Sub RedirectNMakeCommandStreams() Dim nmakeArguments As String = Nothing Dim nmakeProcess As Process - + ' Get the input nmake command-line arguments. Console.WriteLine("Enter the NMake command line arguments" + _ " (@commandfile or /f makefile, etc):") @@ -31,7 +28,7 @@ Class ProcessNMakeStreamRedirection If Not String.IsNullOrEmpty(inputText) Then nmakeArguments = inputText End If - + Console.WriteLine("Enter max line limit for log file (default is 25):") inputText = Console.ReadLine() If Not String.IsNullOrEmpty(inputText) Then @@ -41,26 +38,26 @@ Class ProcessNMakeStreamRedirection End If Console.WriteLine("Output beyond {0} lines will be ignored.", _ maxLogLines) - + ' Initialize the process and its StartInfo properties. nmakeProcess = New Process() nmakeProcess.StartInfo.FileName = "NMake.exe" - + ' Build the nmake command argument list. If Not String.IsNullOrEmpty(nmakeArguments) Then nmakeProcess.StartInfo.Arguments = nmakeArguments End If - + ' Set UseShellExecute to false for redirection. nmakeProcess.StartInfo.UseShellExecute = False - - ' Redirect the standard output of the nmake command. + + ' Redirect the standard output of the nmake command. ' Read the stream asynchronously using an event handler. nmakeProcess.StartInfo.RedirectStandardOutput = True AddHandler nmakeProcess.OutputDataReceived, _ AddressOf NMakeOutputDataHandler - - ' Redirect the error output of the nmake command. + + ' Redirect the error output of the nmake command. nmakeProcess.StartInfo.RedirectStandardError = True AddHandler nmakeProcess.ErrorDataReceived, _ AddressOf NMakeErrorDataHandler @@ -68,10 +65,10 @@ Class ProcessNMakeStreamRedirection logMutex.WaitOne() currentLogLines = 0 - + ' Write a header to the log file. Const buildLogFile As String = "NmakeCmd.Txt" - Try + Try buildLogStream = new StreamWriter(buildLogFile, true) Catch e As Exception Console.WriteLine("Could not open output file {0}", buildLogFile) @@ -82,25 +79,25 @@ Class ProcessNMakeStreamRedirection End Try If Not buildLogStream Is Nothing Then - + Console.WriteLine("Nmake output logged to {0}", _ buildLogFile) - + buildLogStream.WriteLine() buildLogStream.WriteLine(DateTime.Now.ToString()) - + If Not String.IsNullOrEmpty(nmakeArguments) Then buildLogStream.Write("Command line = NMake {0}", _ nmakeArguments) - Else + Else buildLogStream.Write("Command line = Nmake") End If - + buildLogStream.WriteLine() buildLogStream.Flush() - + logMutex.ReleaseMutex() - + ' Start the process. Console.WriteLine() Console.WriteLine("\nStarting Nmake command...") @@ -112,7 +109,7 @@ Class ProcessNMakeStreamRedirection ' Start the asynchronous read of the output stream. nmakeProcess.BeginOutputReadLine() - + ' Let the nmake command run, collecting the output. nmakeProcess.WaitForExit() @@ -120,12 +117,12 @@ Class ProcessNMakeStreamRedirection buildLogStream.Close() logMutex.Dispose() End If - End Sub - + End Sub + Private Shared Sub NMakeOutputDataHandler(sendingProcess As Object, _ outLine As DataReceivedEventArgs) - ' Collect the output, displaying it to the screen and + ' Collect the output, displaying it to the screen and ' logging it to the output file. Cancel the read ' operation when the maximum line limit is reached. @@ -134,35 +131,35 @@ Class ProcessNMakeStreamRedirection currentLogLines = currentLogLines + 1 If currentLogLines > maxLogLines Then - + ' Display the line to the console. ' Skip writing the line to the log file. Console.WriteLine("StdOut: {0}", outLine.Data) Else If currentLogLines = maxLogLines Then - + LogToFile("StdOut", "", _ true) - + ' Stop reading the output streams. - Dim p As Process = sendingProcess + Dim p As Process = sendingProcess If Not (p Is Nothing) Then p.CancelOutputRead() p.CancelErrorRead() End If - Else + Else ' Write the line to the log file. LogToFile("StdOut", outLine.Data, true) End If logMutex.ReleaseMutex() End If - - End Sub - + + End Sub + Private Shared Sub NMakeErrorDataHandler(sendingProcess As Object, _ errLine As DataReceivedEventArgs) - ' Collect the error output, displaying it to the screen and + ' Collect the error output, displaying it to the screen and ' logging it to the output file. Cancel the error output ' read operation when the maximum line limit is reached. @@ -171,31 +168,31 @@ Class ProcessNMakeStreamRedirection currentLogLines = currentLogLines + 1 If currentLogLines > maxLogLines Then - + ' Display the line to the console. ' Skip writing the line to the log file. Console.WriteLine("StdErr: {0}", errLine.Data) Else If currentLogLines = maxLogLines Then - + LogToFile("StdErr", "", _ true) - + ' Stop reading the output streams. - Dim p As Process = sendingProcess + Dim p As Process = sendingProcess If Not (p Is Nothing) Then p.CancelOutputRead() p.CancelErrorRead() End If - Else + Else ' Write the line to the log file. LogToFile("StdErr", errLine.Data, true) End If logMutex.ReleaseMutex() End If - + End Sub - + Private Shared Sub LogToFile(logPrefix As String, _ logText As String, _ echoToConsole As String) @@ -212,29 +209,29 @@ Class ProcessNMakeStreamRedirection End If If Not buildLogStream Is Nothing Then - + buildLogStream.WriteLine("[{0}] {1}", _ DateTime.Now.ToString(), logString.ToString()) buildLogStream.Flush() End If - + If echoToConsole Then Console.WriteLine(logString.ToString()) End If - - End Sub -End Class + + End Sub +End Class ' Namespace ProcessAsyncStreamSamples - + Class ProcessSampleMain ' The main entry point for the application. Shared Sub Main() Try ProcessNMakeStreamRedirection.RedirectNMakeCommandStreams() - + Catch e As InvalidOperationException Console.WriteLine("Exception:") Console.WriteLine(e.ToString()) diff --git a/snippets/visualbasic/System.Diagnostics/DataReceivedEventArgs/Overview/sort_async.vb b/snippets/visualbasic/System.Diagnostics/DataReceivedEventArgs/Overview/sort_async.vb index 6d6cb32fe3a..0143c24bc3a 100644 --- a/snippets/visualbasic/System.Diagnostics/DataReceivedEventArgs/Overview/sort_async.vb +++ b/snippets/visualbasic/System.Diagnostics/DataReceivedEventArgs/Overview/sort_async.vb @@ -1,11 +1,7 @@ ' System.Diagnostics -' -' Requires .NET Framework version 1.2 or higher. -' ' The following example uses the sort command to sort a list -' of input text lines, and displays the sorted list to the console. - +' of input text lines, and displays the sorted list to the console. ' ' Define the namespaces used by this sample. @@ -33,7 +29,7 @@ Namespace ProcessAsyncStreamSamples ' Set UseShellExecute to false for redirection. sortProcess.StartInfo.UseShellExecute = False - ' Redirect the standard output of the sort command. + ' Redirect the standard output of the sort command. ' Read the stream asynchronously using an event handler. sortProcess.StartInfo.RedirectStandardOutput = True sortOutput = New StringBuilder() @@ -54,7 +50,7 @@ Namespace ProcessAsyncStreamSamples ' Start the asynchronous read of the sort output stream. sortProcess.BeginOutputReadLine() - ' Prompt the user for input text lines. Write each + ' Prompt the user for input text lines. Write each ' line to the redirected input stream of the sort command. Console.WriteLine("Ready to sort up to 50 lines of text") diff --git a/snippets/visualbasic/System.Globalization/CultureInfo/CreateSpecificCulture/createspecificculture2.vb b/snippets/visualbasic/System.Globalization/CultureInfo/CreateSpecificCulture/createspecificculture2.vb index 10d163b87f4..70e45180977 100644 --- a/snippets/visualbasic/System.Globalization/CultureInfo/CreateSpecificCulture/createspecificculture2.vb +++ b/snippets/visualbasic/System.Globalization/CultureInfo/CreateSpecificCulture/createspecificculture2.vb @@ -11,11 +11,11 @@ Public Class Example ' Display the header. Console.WriteLine("{0,-53}{1}", "CULTURE", "SPECIFIC CULTURE") - ' Get each neutral culture in the .NET Framework. + ' Get each neutral culture in .NET. Dim cultures() As CultureInfo = CultureInfo.GetCultures(CultureTypes.NeutralCultures) ' Sort the returned array by name. Array.Sort(Of CultureInfo)(cultures, New NamePropertyComparer(Of CultureInfo)()) - + ' Determine the specific culture associated with each neutral culture. For Each culture As CultureInfo In cultures Console.Write("{0,-12} {1,-40}", culture.Name, culture.EnglishName) @@ -24,7 +24,7 @@ Public Class Example Catch e As ArgumentException Console.WriteLine("(no associated specific culture)") End Try - Next + Next End Sub End Class @@ -37,15 +37,15 @@ Public Class NamePropertyComparer(Of T) : Implements IComparer(Of T) Else Return -1 End If - End If + End If Dim pX As PropertyInfo = x.GetType().GetProperty("Name") - Dim pY As PropertyInfo = y.GetType().GetProperty("Name") + Dim pY As PropertyInfo = y.GetType().GetProperty("Name") Return String.Compare(CStr(pX.GetValue(x, Nothing)), CStr(pY.GetValue(y, Nothing))) End Function End Class ' The example displays the following output on a Windows system. This output has been cropped for brevity. ' CULTURE SPECIFIC CULTURE - Invariant Language (Invariant Country) + Invariant Language (Invariant Country) ' aa Afar aa-ET ' af Afrikaans af-ZA ' agq Aghem agq-CM diff --git a/snippets/visualbasic/System.Globalization/PersianCalendar/Overview/calendar2.vb b/snippets/visualbasic/System.Globalization/PersianCalendar/Overview/calendar2.vb index cc9800396fc..20ae61f2a73 100644 --- a/snippets/visualbasic/System.Globalization/PersianCalendar/Overview/calendar2.vb +++ b/snippets/visualbasic/System.Globalization/PersianCalendar/Overview/calendar2.vb @@ -6,104 +6,90 @@ Module Example Dim pc As New PersianCalendar() Dim thisDate As Date = Date.Now - ' Display the current date using the Gregorian and Persian calendars. + ' Display the current date using the Gregorian and Persian calendars. Console.WriteLine("Today in the Gregorian Calendar: {0:dddd}, {0}", thisDate) - Console.WriteLine("Today in the Persian Calendar: {0}, {1}/{2}/{3} {4}:{5}:{6}", + Console.WriteLine("Today in the Persian Calendar: {0}, {1}/{2}/{3} {4}:{5}:{6}", pc.GetDayOfWeek(thisDate), pc.GetMonth(thisDate), - pc.GetDayOfMonth(thisDate), + pc.GetDayOfMonth(thisDate), pc.GetYear(thisDate), pc.GetHour(thisDate), pc.GetMinute(thisDate), pc.GetSecond(thisDate)) Console.WriteLine() - + ' Create a date using the Gregorian calendar. thisDate = New DateTime(2013, 5, 28, 10, 35, 0) Console.WriteLine("Gregorian Calendar: {0:D} ", thisDate) - Console.WriteLine("Persian Calendar: {0}, {1}/{2}/{3} {4}:{5}:{6}", + Console.WriteLine("Persian Calendar: {0}, {1}/{2}/{3} {4}:{5}:{6}", pc.GetDayOfWeek(thisDate), pc.GetMonth(thisDate), - pc.GetDayOfMonth(thisDate), + pc.GetDayOfMonth(thisDate), pc.GetYear(thisDate), pc.GetHour(thisDate), pc.GetMinute(thisDate), pc.GetSecond(thisDate)) Console.WriteLine() - + ' Create a date using the Persian calendar. thisDate = pc.ToDateTime(1395, 4, 22, 12, 30, 0, 0) Console.WriteLine("Gregorian Calendar: {0:D} ", thisDate) - Console.WriteLine("Persian Calendar: {0}, {1}/{2}/{3} {4}:{5}:{6}", + Console.WriteLine("Persian Calendar: {0}, {1}/{2}/{3} {4}:{5}:{6}", pc.GetDayOfWeek(thisDate), pc.GetMonth(thisDate), - pc.GetDayOfMonth(thisDate), + pc.GetDayOfMonth(thisDate), pc.GetYear(thisDate), pc.GetHour(thisDate), pc.GetMinute(thisDate), pc.GetSecond(thisDate)) Console.WriteLine() - + ' Show the Persian Calendar date range. - Console.WriteLine("Minimum Persian Calendar date (Gregorian Calendar): {0:D} ", + Console.WriteLine("Minimum Persian Calendar date (Gregorian Calendar): {0:D} ", pc.MinSupportedDateTime) - Console.WriteLine("Minimum Persian Calendar date (Persian Calendar): " + - "{0}, {1}/{2}/{3} {4}:{5}:{6}", - pc.GetDayOfWeek(pc.MinSupportedDateTime), - pc.GetMonth(pc.MinSupportedDateTime), - pc.GetDayOfMonth(pc.MinSupportedDateTime), - pc.GetYear(pc.MinSupportedDateTime), - pc.GetHour(pc.MinSupportedDateTime), - pc.GetMinute(pc.MinSupportedDateTime), + Console.WriteLine("Minimum Persian Calendar date (Persian Calendar): " + + "{0}, {1}/{2}/{3} {4}:{5}:{6}", + pc.GetDayOfWeek(pc.MinSupportedDateTime), + pc.GetMonth(pc.MinSupportedDateTime), + pc.GetDayOfMonth(pc.MinSupportedDateTime), + pc.GetYear(pc.MinSupportedDateTime), + pc.GetHour(pc.MinSupportedDateTime), + pc.GetMinute(pc.MinSupportedDateTime), pc.GetSecond(pc.MinSupportedDateTime)) Console.WriteLine() - - Console.WriteLine("Maximum Persian Calendar date (Gregorian Calendar): {0:D} ", + + Console.WriteLine("Maximum Persian Calendar date (Gregorian Calendar): {0:D} ", pc.MaxSupportedDateTime) - Console.WriteLine("Maximum Persian Calendar date (Persian Calendar): " + - "{0}, {1}/{2}/{3} {4}:{5}:{6}", - pc.GetDayOfWeek(pc.MaxSupportedDateTime), - pc.GetMonth(pc.MaxSupportedDateTime), - pc.GetDayOfMonth(pc.MaxSupportedDateTime), - pc.GetYear(pc.MaxSupportedDateTime), - pc.GetHour(pc.MinSupportedDateTime), - pc.GetMinute(pc.MaxSupportedDateTime), + Console.WriteLine("Maximum Persian Calendar date (Persian Calendar): " + + "{0}, {1}/{2}/{3} {4}:{5}:{6}", + pc.GetDayOfWeek(pc.MaxSupportedDateTime), + pc.GetMonth(pc.MaxSupportedDateTime), + pc.GetDayOfMonth(pc.MaxSupportedDateTime), + pc.GetYear(pc.MaxSupportedDateTime), + pc.GetHour(pc.MinSupportedDateTime), + pc.GetMinute(pc.MaxSupportedDateTime), pc.GetSecond(pc.MaxSupportedDateTime)) Console.WriteLine() End Sub -End Module -' The example displays the following output when run under the .NET Framework 4.6: -' Today in the Gregorian Calendar: Monday, 2/4/2013 9:11:36 AM -' Today in the Persian Calendar: Monday, 11/16/1391 9:11:36 -' -' Gregorian Calendar: Tuesday, May 28, 2013 -' Persian Calendar: Tuesday, 3/7/1392 10:35:0 -' -' Gregorian Calendar: Tuesday, July 12, 2016 -' Persian Calendar: Tuesday, 4/22/1395 12:30:0 -' -' Minimum Persian Calendar date (Gregorian Calendar): Friday, March 22, 0622 -' Minimum Persian Calendar date (Persian Calendar): Friday, 1/1/1 0:0:0 -' -' Maximum Persian Calendar date (Gregorian Calendar): Friday, December 31, 9999 -' Maximum Persian Calendar date (Persian Calendar): Friday, 10/13/9378 0:59:59 -' -' The example displays the following output when run under versions of -' the .NET Framework before the .NET Framework 4.6: -' Today in the Gregorian Calendar: Monday, 2/4/2013 9:11:36 AM -' Today in the Persian Calendar: Monday, 11/16/1391 9:11:36 +End Module + +' The example displays output similar to the following: + +' Today in the Gregorian Calendar: Thursday, 7/30/2026 4:19:25 PM +' Today in the Persian Calendar: Thursday, 5/8/1405 16:19:25 ' -' Gregorian Calendar: Tuesday, May 28, 2013 -' Persian Calendar: Tuesday, 3/7/1392 10:35:0 +' Gregorian Calendar: Tuesday, May 28, 2013 +' Persian Calendar: Tuesday, 3/7/1392 10:35:0 ' -' Gregorian Calendar: Tuesday, July 12, 2016 -' Persian Calendar: Tuesday, 4/22/1395 12:30:0 +' Gregorian Calendar: Tuesday, July 12, 2016 +' Persian Calendar: Tuesday, 4/22/1395 12:30:0 ' -' Minimum Persian Calendar date (Gregorian Calendar): Thursday, March 21, 0622 -' Minimum Persian Calendar date (Persian Calendar): Thursday, 1/1/1 0:0:0 +' Minimum Persian Calendar date (Gregorian Calendar): Friday, March 22, 0622 +' Minimum Persian Calendar date (Persian Calendar): Friday, 1/1/1 0:0:0 ' -' Maximum Persian Calendar date (Gregorian Calendar): Friday, December 31, 9999 -' Maximum Persian Calendar date (Persian Calendar): Friday, 10/10/9378 0:59:59 +' Maximum Persian Calendar date (Gregorian Calendar): Friday, December 31, 9999 +' Maximum Persian Calendar date (Persian Calendar): Friday, 10/13/9378 0:59:59 + ' diff --git a/snippets/visualbasic/System.Globalization/TextInfo/Clone/ro.vb b/snippets/visualbasic/System.Globalization/TextInfo/Clone/ro.vb index 77710a04327..a2088bcbf71 100644 --- a/snippets/visualbasic/System.Globalization/TextInfo/Clone/ro.vb +++ b/snippets/visualbasic/System.Globalization/TextInfo/Clone/ro.vb @@ -5,39 +5,39 @@ Imports System.Globalization Class Sample - Public Shared Sub Main() - ' Get the TextInfo of a predefined culture that ships with - ' the .NET Framework. + Public Shared Sub Main() + ' Get the TextInfo of a predefined culture that ships with + ' .NET. Dim ci As New CultureInfo("en-US") Dim ti1 As TextInfo = ci.TextInfo - + ' Display whether the TextInfo is read-only or not. DisplayReadOnly("1) The original TextInfo object", ti1) Console.WriteLine() - + ' Create a clone of the original TextInfo and cast the clone to a TextInfo type. Console.WriteLine("2a) Create a clone of the original TextInfo object...") Dim ti2 As TextInfo = CType(ti1.Clone(), TextInfo) - + ' Display whether the clone is read-only. DisplayReadOnly("2b) The TextInfo clone", ti2) - + ' Set the ListSeparator property on the TextInfo clone. Console.WriteLine("2c) The original value of the clone's ListSeparator " & _ "property is ""{0}"".", ti2.ListSeparator) ti2.ListSeparator = "/" - Console.WriteLine("2d) The new value of the clone's ListSeparator " & _ + Console.WriteLine("2d) The new value of the clone's ListSeparator " & _ "property is ""{0}""." & vbCrLf, ti2.ListSeparator) - + ' Create a read-only clone of the original TextInfo. Console.WriteLine("3a) Create a read-only clone of the original TextInfo object...") Dim ti3 As TextInfo = TextInfo.ReadOnly(ti1) - + ' Display whether the read-only clone is actually read-only. DisplayReadOnly("3b) The TextInfo clone", ti3) - + ' Try to set the ListSeparator property of a read-only TextInfo object. Use the - ' IsReadOnly property again to determine whether to attempt the set operation. You + ' IsReadOnly property again to determine whether to attempt the set operation. You ' could use a try-catch block instead and catch an InvalidOperationException when ' the set operation fails, but that programming technique is inefficient. Console.WriteLine("3c) Try to set the read-only clone's LineSeparator property.") @@ -46,19 +46,19 @@ Class Sample Else ' This clause is not executed. ti3.ListSeparator = "/" - Console.WriteLine("3d) The new value of the clone's ListSeparator " & _ + Console.WriteLine("3d) The new value of the clone's ListSeparator " & _ "property is ""{0}""." & vbCrLf, ti2.ListSeparator) End If - + End Sub - + Private Shared Sub DisplayReadOnly(ByVal caption As String, ByVal ti As TextInfo) Dim middle As String If ti.IsReadOnly = True Then middle = "" - Else + Else middle = "not " - End If + End If Console.WriteLine("{0} is {1}read-only.", caption, middle) End Sub End Class @@ -78,4 +78,4 @@ End Class '3c) Try to set the read-only clone's LineSeparator property. '3d) The set operation is invalid. ' -' \ No newline at end of file +' diff --git a/snippets/visualbasic/System.Runtime.InteropServices/DllImportAttribute/PreserveSig/example.vb b/snippets/visualbasic/System.Runtime.InteropServices/DllImportAttribute/PreserveSig/example.vb index c6a32481dc3..d9331696926 100644 --- a/snippets/visualbasic/System.Runtime.InteropServices/DllImportAttribute/PreserveSig/example.vb +++ b/snippets/visualbasic/System.Runtime.InteropServices/DllImportAttribute/PreserveSig/example.vb @@ -6,30 +6,24 @@ Imports System.Runtime.InteropServices Module Win32 - ' The SHAutoComplete function allows you + ' The SHAutoComplete function allows you ' to add auto-compete functionality to your - ' Windows Forms text boxes. In .NET Framework - ' 1.1 and earlier, you can use SHAutoComplete. - ' Later versions have this ability built in without - ' requiring platform invoke. - ' See the MSDN documentation of the - ' SHAutoComplete function for the - ' complete set of flags. + ' Windows Forms text boxes. Public Enum SHAutoCompleteFlags SHACF_DEFAULT = &H1 SHACF_FILESYSTEM = &H1 - End Enum + End Enum - ' Use the DllImportAttribute to import the SHAutoComplete function. + ' Use the DllImportAttribute to import the SHAutoComplete function. ' Set the PreserveSig to false to specify exception errors. _ Public Sub SHAutoComplete(ByVal hwndEdit As IntPtr, ByVal dwFlags As SHAutoCompleteFlags) End Sub - ' Use the DllImportAttribute to import the SHAutoComplete function. + ' Use the DllImportAttribute to import the SHAutoComplete function. ' Use the default value of the PreserveSig field to specify HRESULT errors. _ Public Function SHAutoCompleteHRESULT(ByVal hwndEdit As IntPtr, ByVal dwFlags As SHAutoCompleteFlags) As Integer @@ -49,9 +43,9 @@ Module Program Sub Run() ' Create a null (nothing in Visual Basic) IntPtr ' to pass to the SHAutoComplete method. Doing so - ' creates a failure and demonstrates the two ways - ' that the PreserveSig property allows you to handle - ' failures. + ' creates a failure and demonstrates the two ways + ' that the PreserveSig property allows you to handle + ' failures. ' Normally, you would pass a handle to a managed ' Windows Forms text box. Dim iPtr As New IntPtr(0) @@ -74,4 +68,4 @@ Module Program End Sub End Module -' \ No newline at end of file +' diff --git a/snippets/visualbasic/System.Runtime.InteropServices/MarshalAsAttribute/SizeParamIndex/marshalas.sizeparamindex.vb b/snippets/visualbasic/System.Runtime.InteropServices/MarshalAsAttribute/SizeParamIndex/marshalas.sizeparamindex.vb index 8094e36924a..7fb41f89a87 100644 --- a/snippets/visualbasic/System.Runtime.InteropServices/MarshalAsAttribute/SizeParamIndex/marshalas.sizeparamindex.vb +++ b/snippets/visualbasic/System.Runtime.InteropServices/MarshalAsAttribute/SizeParamIndex/marshalas.sizeparamindex.vb @@ -6,8 +6,8 @@ Imports SomeNamespace Namespace SomeNamespace ' Force the layout of your fields to the C style struct layout. - ' Without this, the .NET Framework will reorder your fields. - + ' Without this, .NET will reorder your fields. + _ Structure Vertex Dim x As Decimal @@ -22,7 +22,7 @@ Namespace SomeNamespace Declare Auto Sub SomeUnsafeMethod Lib "somelib.dll" ( _ data() As Vertex, _ - size As Long ) + size As Long ) Public Sub SomeMethod() Dim verts(3) As Vertex diff --git a/snippets/visualbasic/System.Runtime.Versioning/FrameworkName/op_Equality/Operators1.vb b/snippets/visualbasic/System.Runtime.Versioning/FrameworkName/op_Equality/Operators1.vb index 10aacbbc053..c84ad8acd8f 100644 --- a/snippets/visualbasic/System.Runtime.Versioning/FrameworkName/op_Equality/Operators1.vb +++ b/snippets/visualbasic/System.Runtime.Versioning/FrameworkName/op_Equality/Operators1.vb @@ -8,46 +8,52 @@ Module Example TestForEquality() TestForInequality() End Sub - + Private Sub TestForEquality() ' - Dim supportedVer1 As New FrameworkName(".NET Framework, Version=4.0") - Dim actualVersion As New FrameworkName(String.Format(".NET Framework, Version={0}", - Environment.Version.ToString())) - - Console.WriteLine("Supported Version: {0}", supportedVer1) - Console.WriteLine("Actual Version: {0}", actualVersion) - If supportedVer1 = actualVersion Then - Console.WriteLine("The supported and actual Framework versions are the same.") + Dim version As New FrameworkName(".NET, Version=10.0") + Dim actualVersion As New FrameworkName($".NET, Version={Environment.Version}") + + Console.WriteLine($"Given Version: {version}") + Console.WriteLine($"Actual Version: {actualVersion}") + If version = actualVersion Then + Console.WriteLine("The versions are the same.") Else - Console.WriteLine("The supported and actual Framework versions are different.") - End If + Console.WriteLine("The versions are different.") + End If + Console.WriteLine() - ' The example displays the following output: - ' Supported Version: .NET Framework,Version=v4.0 - ' Actual Version: .NET Framework,Version=v4.0.30319.18010 - ' The supported and actual Framework versions are different. - ' + + ' The example displays output similar to the following: + + ' Given Version: .NET,Version=v10.0 + ' Actual Version: .NET,Version=v10.0.10 + ' The versions are different. + + ' End Sub - + Private Sub TestForInequality() ' - Dim supportedVer1 As New FrameworkName(".NET Framework, Version=4.0") - Dim actualVersion As New FrameworkName(String.Format(".NET Framework, Version={0}", - Environment.Version.ToString())) - - Console.WriteLine("Supported Version: {0}", supportedVer1) - Console.WriteLine("Actual Version: {0}", actualVersion) - If supportedVer1 <> actualVersion Then - Console.WriteLine("The supported and actual Framework versions are different.") + Dim version As New FrameworkName(".NET, Version=10.0") + Dim actualVersion As New FrameworkName($".NET, Version={Environment.Version}") + + Console.WriteLine($"Given Version: {version}") + Console.WriteLine($"Actual Version {actualVersion}") + If version <> actualVersion Then + Console.WriteLine("The versions are different.") Else - Console.WriteLine("The supported and actual Framework versions are the same.") - End If + Console.WriteLine("The versions are the same.") + End If + Console.WriteLine() - ' The example displays the following output: - ' Supported Version: .NET Framework,Version=v4.0 - ' Actual Version: .NET Framework,Version=v4.0.30319.18010 - ' The supported and actual Framework versions are different. + + ' The example displays output similar to the following: + + ' Given Version: .NET,Version=v10.0 + ' Actual Version: .NET,Version=v10.0.10 + ' The versions are different. + ' End Sub End Module diff --git a/snippets/visualbasic/System.ServiceProcess/SessionChangeDescription/Overview/simpleservice.vb b/snippets/visualbasic/System.ServiceProcess/SessionChangeDescription/Overview/simpleservice.vb index 582577243fb..ef65a22b56a 100644 --- a/snippets/visualbasic/System.ServiceProcess/SessionChangeDescription/Overview/simpleservice.vb +++ b/snippets/visualbasic/System.ServiceProcess/SessionChangeDescription/Overview/simpleservice.vb @@ -113,7 +113,7 @@ Public Class SimpleService SetServiceStatus(handle, myServiceStatus) System.Diagnostics.EventLog.WriteEntry("SimpleService", "Starting SimpleService") - ' Get arguments from the ImagePath string value for the service's registry + ' Get arguments from the ImagePath string value for the service's registry ' key (HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\SimpleService). ' These arguments are not used by this sample, this code is only intended to ' demonstrate how to obtain the arguments. @@ -143,7 +143,6 @@ Public Class SimpleService ' ' Stop this service. Protected Overrides Sub OnStop() - ' New in .NET Framework version 2.0. Me.RequestAdditionalTime(4000) ' Signal the worker thread to exit. If Not (workerThread Is Nothing) AndAlso workerThread.IsAlive Then @@ -299,8 +298,8 @@ Public Class SimpleService End Sub ' - ' Define a simple method that runs as the worker thread for - ' the service. + ' Define a simple method that runs as the worker thread for + ' the service. Public Sub ServiceWorkerMethod() #If LOGEVENTS Then System.Diagnostics.EventLog.WriteEntry("SimpleService.WorkerThread", DateTime.Now.ToLongTimeString() + " - Starting the service worker thread.") @@ -319,7 +318,7 @@ Public Class SimpleService Catch ' Another thread has signalled that this worker ' thread must terminate. Typically, this occurs when - ' the main service thread receives a service stop + ' the main service thread receives a service stop ' command. ' Write a trace line indicating that the worker thread ' is exiting. Notice that this simple thread does @@ -335,4 +334,4 @@ Public Class SimpleService End Sub End Class -' \ No newline at end of file +' diff --git a/snippets/visualbasic/System.Text/EncodingInfo/Overview/encodinginfo.vb b/snippets/visualbasic/System.Text/EncodingInfo/Overview/encodinginfo.vb index 508916ce403..ca380322f9b 100644 --- a/snippets/visualbasic/System.Text/EncodingInfo/Overview/encodinginfo.vb +++ b/snippets/visualbasic/System.Text/EncodingInfo/Overview/encodinginfo.vb @@ -24,21 +24,21 @@ Public Class SamplesEncoding Console.Write(" ") Else Console.Write("*** ") - End If + End If Console.Write("{0,-25}", ei.Name) If ei.CodePage = e.CodePage Then Console.Write(" ") Else Console.Write("*** ") - End If + End If Console.Write("{0,-25}", ei.DisplayName) If ei.CodePage = e.CodePage Then Console.Write(" ") Else Console.Write("*** ") - End If + End If Console.WriteLine() Next ei @@ -46,159 +46,16 @@ Public Class SamplesEncoding End Class -' The example displays the following output when run on .NET Core: +' The example displays the following output: ' ' Info.CodePage Info.Name Info.DisplayName -' 1200 utf-16 Unicode -' 1201 utf-16BE Unicode (Big-Endian) -' 12000 utf-32 Unicode (UTF-32) -' 12001 utf-32BE Unicode (UTF-32 Big-Endian) -' 20127 us-ascii US-ASCII -' 28591 iso-8859-1 Western European (ISO) -' 65000 utf-7 Unicode (UTF-7) -' 65001 utf-8 Unicode (UTF-8) -' -' The example displays the following output when run on the .NET Framework: -' -' Info.CodePage Info.Name Info.DisplayName -' 37 IBM037 IBM EBCDIC (US-Canada) -' 437 IBM437 OEM United States -' 500 IBM500 IBM EBCDIC (International) -' 708 ASMO-708 Arabic (ASMO 708) -' 720 DOS-720 Arabic (DOS) -' 737 ibm737 Greek (DOS) -' 775 ibm775 Baltic (DOS) -' 850 ibm850 Western European (DOS) -' 852 ibm852 Central European (DOS) -' 855 IBM855 OEM Cyrillic -' 857 ibm857 Turkish (DOS) -' 858 IBM00858 OEM Multilingual Latin I -' 860 IBM860 Portuguese (DOS) -' 861 ibm861 Icelandic (DOS) -' 862 DOS-862 Hebrew (DOS) -' 863 IBM863 French Canadian (DOS) -' 864 IBM864 Arabic (864) -' 865 IBM865 Nordic (DOS) -' 866 cp866 Cyrillic (DOS) -' 869 ibm869 Greek, Modern (DOS) -' 870 IBM870 IBM EBCDIC (Multilingual Latin-2) -' 874 windows-874 Thai (Windows) -' 875 cp875 IBM EBCDIC (Greek Modern) -' 932 shift_jis Japanese (Shift-JIS) -' 936 gb2312 Chinese Simplified (GB2312) -' 949 ks_c_5601-1987 Korean -' 950 big5 Chinese Traditional (Big5) -' 1026 IBM1026 IBM EBCDIC (Turkish Latin-5) -' 1047 IBM01047 IBM Latin-1 -' 1140 IBM01140 IBM EBCDIC (US-Canada-Euro) -' 1141 IBM01141 IBM EBCDIC (Germany-Euro) -' 1142 IBM01142 IBM EBCDIC (Denmark-Norway-Euro) -' 1143 IBM01143 IBM EBCDIC (Finland-Sweden-Euro) -' 1144 IBM01144 IBM EBCDIC (Italy-Euro) -' 1145 IBM01145 IBM EBCDIC (Spain-Euro) -' 1146 IBM01146 IBM EBCDIC (UK-Euro) -' 1147 IBM01147 IBM EBCDIC (France-Euro) -' 1148 IBM01148 IBM EBCDIC (International-Euro) -' 1149 IBM01149 IBM EBCDIC (Icelandic-Euro) -' 1200 utf-16 Unicode -' 1201 utf-16BE Unicode (Big-Endian) -' 1250 windows-1250 Central European (Windows) -' 1251 windows-1251 Cyrillic (Windows) -' 1252 Windows-1252 Western European (Windows) -' 1253 windows-1253 Greek (Windows) -' 1254 windows-1254 Turkish (Windows) -' 1255 windows-1255 Hebrew (Windows) -' 1256 windows-1256 Arabic (Windows) -' 1257 windows-1257 Baltic (Windows) -' 1258 windows-1258 Vietnamese (Windows) -' 1361 Johab Korean (Johab) -' 10000 macintosh Western European (Mac) -' 10001 x-mac-japanese Japanese (Mac) -' 10002 x-mac-chinesetrad Chinese Traditional (Mac) -' 10003 x-mac-korean Korean (Mac) -' 10004 x-mac-arabic Arabic (Mac) -' 10005 x-mac-hebrew Hebrew (Mac) -' 10006 x-mac-greek Greek (Mac) -' 10007 x-mac-cyrillic Cyrillic (Mac) -' 10008 x-mac-chinesesimp Chinese Simplified (Mac) -' 10010 x-mac-romanian Romanian (Mac) -' 10017 x-mac-ukrainian Ukrainian (Mac) -' 10021 x-mac-thai Thai (Mac) -' 10029 x-mac-ce Central European (Mac) -' 10079 x-mac-icelandic Icelandic (Mac) -' 10081 x-mac-turkish Turkish (Mac) -' 10082 x-mac-croatian Croatian (Mac) -' 12000 utf-32 Unicode (UTF-32) -' 12001 utf-32BE Unicode (UTF-32 Big-Endian) -' 20000 x-Chinese-CNS Chinese Traditional (CNS) -' 20001 x-cp20001 TCA Taiwan -' 20002 x-Chinese-Eten Chinese Traditional (Eten) -' 20003 x-cp20003 IBM5550 Taiwan -' 20004 x-cp20004 TeleText Taiwan -' 20005 x-cp20005 Wang Taiwan -' 20105 x-IA5 Western European (IA5) -' 20106 x-IA5-German German (IA5) -' 20107 x-IA5-Swedish Swedish (IA5) -' 20108 x-IA5-Norwegian Norwegian (IA5) -' 20127 us-ascii US-ASCII -' 20261 x-cp20261 T.61 -' 20269 x-cp20269 ISO-6937 -' 20273 IBM273 IBM EBCDIC (Germany) -' 20277 IBM277 IBM EBCDIC (Denmark-Norway) -' 20278 IBM278 IBM EBCDIC (Finland-Sweden) -' 20280 IBM280 IBM EBCDIC (Italy) -' 20284 IBM284 IBM EBCDIC (Spain) -' 20285 IBM285 IBM EBCDIC (UK) -' 20290 IBM290 IBM EBCDIC (Japanese katakana) -' 20297 IBM297 IBM EBCDIC (France) -' 20420 IBM420 IBM EBCDIC (Arabic) -' 20423 IBM423 IBM EBCDIC (Greek) -' 20424 IBM424 IBM EBCDIC (Hebrew) -' 20833 x-EBCDIC-KoreanExtended IBM EBCDIC (Korean Extended) -' 20838 IBM-Thai IBM EBCDIC (Thai) -' 20866 koi8-r Cyrillic (KOI8-R) -' 20871 IBM871 IBM EBCDIC (Icelandic) -' 20880 IBM880 IBM EBCDIC (Cyrillic Russian) -' 20905 IBM905 IBM EBCDIC (Turkish) -' 20924 IBM00924 IBM Latin-1 -' 20932 EUC-JP Japanese (JIS 0208-1990 and 0212-1990) -' 20936 x-cp20936 Chinese Simplified (GB2312-80) -' 20949 x-cp20949 Korean Wansung -' 21025 cp1025 IBM EBCDIC (Cyrillic Serbian-Bulgarian) -' 21866 koi8-u Cyrillic (KOI8-U) -' 28591 iso-8859-1 Western European (ISO) -' 28592 iso-8859-2 Central European (ISO) -' 28593 iso-8859-3 Latin 3 (ISO) -' 28594 iso-8859-4 Baltic (ISO) -' 28595 iso-8859-5 Cyrillic (ISO) -' 28596 iso-8859-6 Arabic (ISO) -' 28597 iso-8859-7 Greek (ISO) -' 28598 iso-8859-8 Hebrew (ISO-Visual) -' 28599 iso-8859-9 Turkish (ISO) -' 28603 iso-8859-13 Estonian (ISO) -' 28605 iso-8859-15 Latin 9 (ISO) -' 29001 x-Europa Europa -' 38598 iso-8859-8-i Hebrew (ISO-Logical) -' 50220 iso-2022-jp Japanese (JIS) -' 50221 csISO2022JP Japanese (JIS-Allow 1 byte Kana) -' 50222 iso-2022-jp Japanese (JIS-Allow 1 byte Kana - SO/SI) -' 50225 iso-2022-kr Korean (ISO) -' 50227 x-cp50227 Chinese Simplified (ISO-2022) -' 51932 euc-jp Japanese (EUC) -' 51936 EUC-CN Chinese Simplified (EUC) -' 51949 euc-kr Korean (EUC) -' 52936 hz-gb-2312 Chinese Simplified (HZ) -' 54936 GB18030 Chinese Simplified (GB18030) -' 57002 x-iscii-de ISCII Devanagari -' 57003 x-iscii-be ISCII Bengali -' 57004 x-iscii-ta ISCII Tamil -' 57005 x-iscii-te ISCII Telugu -' 57006 x-iscii-as ISCII Assamese -' 57007 x-iscii-or ISCII Oriya -' 57008 x-iscii-ka ISCII Kannada -' 57009 x-iscii-ma ISCII Malayalam -' 57010 x-iscii-gu ISCII Gujarati -' 57011 x-iscii-pa ISCII Punjabi -' 65000 utf-7 Unicode (UTF-7) -' 65001 utf-8 Unicode (UTF-8) -' \ No newline at end of file +' 1200 utf-16 Unicode +' 1201 utf-16BE Unicode (Big-Endian) +' 12000 utf-32 Unicode (UTF-32) +' 12001 utf-32BE Unicode (UTF-32 Big-Endian) +' 20127 us-ascii US-ASCII +' 28591 iso-8859-1 Western European (ISO) +' 65000 utf-7 Unicode (UTF-7) +' 65001 utf-8 Unicode (UTF-8) + +' diff --git a/snippets/visualbasic/System.Text/StringBuilder/Capacity/cap.vb b/snippets/visualbasic/System.Text/StringBuilder/Capacity/cap.vb index ec8fcad704e..2ee81c2de5e 100644 --- a/snippets/visualbasic/System.Text/StringBuilder/Capacity/cap.vb +++ b/snippets/visualbasic/System.Text/StringBuilder/Capacity/cap.vb @@ -9,57 +9,57 @@ Class Sample Public Shared Sub Main() Dim sb1 As New StringBuilder("abc") Dim sb2 As New StringBuilder("abc", 16) - + Console.WriteLine() Console.WriteLine("a1) sb1.Length = {0}, sb1.Capacity = {1}", sb1.Length, sb1.Capacity) Console.WriteLine("a2) sb2.Length = {0}, sb2.Capacity = {1}", sb2.Length, sb2.Capacity) Console.WriteLine("a3) sb1.ToString() = ""{0}"", sb2.ToString() = ""{1}""", _ sb1.ToString(), sb2.ToString()) Console.WriteLine("a4) sb1 equals sb2: {0}", sb1.Equals(sb2)) - + Console.WriteLine() Console.WriteLine("Ensure sb1 has a capacity of at least 50 characters.") sb1.EnsureCapacity(50) - + Console.WriteLine() Console.WriteLine("b1) sb1.Length = {0}, sb1.Capacity = {1}", sb1.Length, sb1.Capacity) Console.WriteLine("b2) sb2.Length = {0}, sb2.Capacity = {1}", sb2.Length, sb2.Capacity) Console.WriteLine("b3) sb1.ToString() = ""{0}"", sb2.ToString() = ""{1}""", _ sb1.ToString(), sb2.ToString()) Console.WriteLine("b4) sb1 equals sb2: {0}", sb1.Equals(sb2)) - + Console.WriteLine() Console.WriteLine("Set the length of sb1 to zero.") Console.WriteLine("Set the capacity of sb2 to 51 characters.") sb1.Length = 0 sb2.Capacity = 51 - + Console.WriteLine() Console.WriteLine("c1) sb1.Length = {0}, sb1.Capacity = {1}", sb1.Length, sb1.Capacity) Console.WriteLine("c2) sb2.Length = {0}, sb2.Capacity = {1}", sb2.Length, sb2.Capacity) Console.WriteLine("c3) sb1.ToString() = ""{0}"", sb2.ToString() = ""{1}""", _ sb1.ToString(), sb2.ToString()) Console.WriteLine("c4) sb1 equals sb2: {0}", sb1.Equals(sb2)) - End Sub + End Sub End Class 'The example displays the following output: ' a1) sb1.Length = 3, sb1.Capacity = 16 ' a2) sb2.Length = 3, sb2.Capacity = 16 ' a3) sb1.ToString() = "abc", sb2.ToString() = "abc" ' a4) sb1 equals sb2: True -' +' ' Ensure sb1 has a capacity of at least 50 characters. -' +' ' b1) sb1.Length = 3, sb1.Capacity = 50 ' b2) sb2.Length = 3, sb2.Capacity = 16 ' b3) sb1.ToString() = "abc", sb2.ToString() = "abc" -' b4) sb1 equals sb2: True (False on .NET Framework) -' +' b4) sb1 equals sb2: True +' ' Set the length of sb1 to zero. ' Set the capacity of sb2 to 51 characters. -' +' ' c1) sb1.Length = 0, sb1.Capacity = 50 ' c2) sb2.Length = 3, sb2.Capacity = 51 ' c3) sb1.ToString() = "", sb2.ToString() = "abc" ' c4) sb1 equals sb2: False -' \ No newline at end of file +' diff --git a/snippets/visualbasic/System.Threading/SpinWait/Overview/spinwait.vb b/snippets/visualbasic/System.Threading/SpinWait/Overview/spinwait.vb index 0ce95d56c40..06649b64ed5 100644 --- a/snippets/visualbasic/System.Threading/SpinWait/Overview/spinwait.vb +++ b/snippets/visualbasic/System.Threading/SpinWait/Overview/spinwait.vb @@ -26,7 +26,7 @@ Module SpinWaitDemo sw.SpinOnce() End While - ' As of .NET Framework 4: After some initial spinning, SpinWait.SpinOnce() will yield every time. + ' After some initial spinning, SpinWait.SpinOnce() will yield every time. Console.WriteLine("SpinWait called {0} times, yielded {1} times", sw.Count, numYields) End Sub) @@ -42,4 +42,4 @@ Module SpinWaitDemo End Sub End Module -' \ No newline at end of file +' diff --git a/snippets/visualbasic/System/Console/Overview/example3.vb b/snippets/visualbasic/System/Console/Overview/example3.vb index d18c90ab074..c5cf97dab78 100644 --- a/snippets/visualbasic/System/Console/Overview/example3.vb +++ b/snippets/visualbasic/System/Console/Overview/example3.vb @@ -23,36 +23,35 @@ Public Module DisplayChars If Not UInt32.TryParse(args(0), NumberStyles.HexNumber, Nothing, rangeStart) Then Throw New ArgumentException(String.Format("{0} is not a valid hexadecimal number.", args(0))) End If - + If Not UInt32.TryParse(args(1), NumberStyles.HexNumber, Nothing, rangeEnd) Then Throw New ArgumentException(String.Format("{0} is not a valid hexadecimal number.", args(1))) End If - + Boolean.TryParse(args(2), setOutputEncodingToUnicode) Case Else - Console.WriteLine("Usage: {0} <{1}> <{2}> [{3}]", - Environment.GetCommandLineArgs()(0), - "startingCodePointInHex", - "endingCodePointInHex", + Console.WriteLine("Usage: {0} <{1}> <{2}> [{3}]", + Environment.GetCommandLineArgs()(0), + "startingCodePointInHex", + "endingCodePointInHex", "") Exit Sub End Select - + If setOutputEncodingToUnicode Then - ' This won't work before .NET Framework 4.5. - Try + Try ' Set encoding Imports endianness of this system. - ' We're interested in displaying individual Char objects, so + ' We're interested in displaying individual Char objects, so ' we don't want a Unicode BOM or exceptions to be thrown on ' invalid Char values. - Console.OutputEncoding = New UnicodeEncoding(Not BitConverter.IsLittleEndian, False) + Console.OutputEncoding = New UnicodeEncoding(Not BitConverter.IsLittleEndian, False) Console.WriteLine("{0}Output encoding set to UTF-16", vbCrLf) Catch e As IOException Console.OutputEncoding = New UTF8Encoding() Console.WriteLine("Output encoding set to UTF-8") End Try Else - Console.WriteLine("The console encoding is {0} (code page {1})", + Console.WriteLine("The console encoding is {0} (code page {1})", Console.OutputEncoding.EncodingName, Console.OutputEncoding.CodePage) End If @@ -69,7 +68,7 @@ Public Module DisplayChars Const upperRange As UInteger = &h10FFFF Const surrogateStart As UInteger = &hD800 Const surrogateEnd As UInteger = &hDFFF - + If rangeEnd <= rangeStart Then Dim t As UInteger = rangeStart rangeStart = rangeEnd @@ -79,7 +78,7 @@ Public Module DisplayChars ' Check whether the start or end range is outside of last plane. If rangeStart > upperRange Then Throw New ArgumentException(String.Format("0x{0:X5} is outside the upper range of Unicode code points (0x{1:X5})", - rangeStart, upperRange)) + rangeStart, upperRange)) End If If rangeEnd > upperRange Then Throw New ArgumentException(String.Format("0x{0:X5} is outside the upper range of Unicode code points (0x{0:X5})", @@ -87,10 +86,10 @@ Public Module DisplayChars End If ' Since we're using 21-bit code points, we can't use U+D800 to U+DFFF. If (rangeStart < surrogateStart And rangeEnd > surrogateStart) OrElse (rangeStart >= surrogateStart And rangeStart <= surrogateEnd ) - Throw New ArgumentException(String.Format("0x{0:X5}-0x{1:X5} includes the surrogate pair range 0x{2:X5}-0x{3:X5}", - rangeStart, rangeEnd, surrogateStart, surrogateEnd)) + Throw New ArgumentException(String.Format("0x{0:X5}-0x{1:X5} includes the surrogate pair range 0x{2:X5}-0x{3:X5}", + rangeStart, rangeEnd, surrogateStart, surrogateEnd)) End If - + Dim last As UInteger = RoundUpToMultipleOf(&h10, rangeEnd) Dim first As UInteger = RoundDownToMultipleOf(&h10, rangeStart) @@ -106,11 +105,11 @@ Public Module DisplayChars Console.Write(" {0} ", Convert.ToChar(&h20)) Else If rangeEnd < cur Then Console.Write(" {0} ", Convert.ToChar(&h20)) - Else + Else ' the cast to int is safe, since we know that val <= upperRange. Dim chars As String = Char.ConvertFromUtf32(CInt(cur)) ' Display a space for code points that are not valid characters. - If CharUnicodeInfo.GetUnicodeCategory(chars(0)) = + If CharUnicodeInfo.GetUnicodeCategory(chars(0)) = UnicodeCategory.OtherNotAssigned Then Console.Write(" {0} ", Convert.ToChar(&h20)) ' Display a space for code points in the private use area. @@ -120,14 +119,14 @@ Public Module DisplayChars ' Is surrogate pair a valid character? ' Note that the console will interpret the high and low surrogate ' as separate (and unrecognizable) characters. - Else If chars.Length > 1 AndAlso CharUnicodeInfo.GetUnicodeCategory(chars, 0) = + Else If chars.Length > 1 AndAlso CharUnicodeInfo.GetUnicodeCategory(chars, 0) = UnicodeCategory.OtherNotAssigned Then Console.Write(" {0} ", Convert.ToChar(&h20)) Else - Console.Write(" {0} ", chars) - End If + Console.Write(" {0} ", chars) + End If End If - + Select Case c Case 3, 11 Console.Write("-") diff --git a/snippets/visualbasic/System/Convert/ToBoolean/system.convert snippet.vb b/snippets/visualbasic/System/Convert/ToBoolean/system.convert snippet.vb index 6101a103fc3..966b06423a9 100644 --- a/snippets/visualbasic/System/Convert/ToBoolean/system.convert snippet.vb +++ b/snippets/visualbasic/System/Convert/ToBoolean/system.convert snippet.vb @@ -51,7 +51,7 @@ boolVal = System.Convert.ToBoolean(dateTime) Catch exception As System.InvalidCastException System.Console.WriteLine("Conversion from DateTime to " + _ - "Boolean is not supported by the .NET Framework.") + "Boolean is not supported by .NET.") End Try End Sub ' @@ -118,7 +118,7 @@ Catch exception As System.InvalidCastException System.Console.WriteLine( _ "Char-to-Decimal conversion is not supported " + _ - "by the .NET Framework.") + "by .NET.") End Try 'Decimal to char conversion is also not supported. @@ -127,7 +127,7 @@ Catch exception As System.InvalidCastException System.Console.WriteLine( _ "Decimal-to-Char conversion is not supported " + _ - "by the .NET Framework.") + "by .NET.") End Try End Sub ' @@ -139,7 +139,7 @@ ConvertDoubleDecimal(CDec(doubleVal)) CovertDoubleFloat(doubleVal) ConvertDoubleString(doubleVal) - End Sub + End Sub ' Public Sub ConvertDoubleBool(ByVal doubleVal As Double) @@ -187,7 +187,7 @@ doubleVal = System.Convert.ToDouble(decimalVal) System.Console.WriteLine("{0} as a Double is: {1}", _ decimalVal, doubleVal) - + ' Conversion from Double to Decimal can overflow. Try decimalVal = System.Convert.ToDecimal(doubleVal) @@ -243,7 +243,7 @@ Dim stringVal As String - ' A conversion from Double to String cannot overflow. + ' A conversion from Double to String cannot overflow. stringVal = System.Convert.ToString(doubleVal) System.Console.WriteLine("{0} as a String is: {1}", _ doubleVal, stringVal) diff --git a/snippets/visualbasic/System/Single/Overview/PrecisionList4a.vb b/snippets/visualbasic/System/Single/Overview/PrecisionList4a.vb deleted file mode 100644 index 7e9692ec3f7..00000000000 --- a/snippets/visualbasic/System/Single/Overview/PrecisionList4a.vb +++ /dev/null @@ -1,37 +0,0 @@ -' Visual Basic .NET Document -Option Strict On - -Imports System.IO - -Module Example11 - Public Sub Main() - ' - Dim sw As New StreamWriter(".\Singles.dat") - Dim values() As Single = {3.2 / 1.11, 1.0 / 3, CSng(Math.PI)} - For ctr As Integer = 0 To values.Length - 1 - sw.Write(values(ctr).ToString()) - If ctr <> values.Length - 1 Then sw.Write("|") - Next - sw.Close() - - Dim restoredValues(values.Length - 1) As Single - Dim sr As New StreamReader(".\Singles.dat") - Dim temp As String = sr.ReadToEnd() - Dim tempStrings() As String = temp.Split("|"c) - For ctr As Integer = 0 To tempStrings.Length - 1 - restoredValues(ctr) = Single.Parse(tempStrings(ctr)) - Next - - For ctr As Integer = 0 To values.Length - 1 - Console.WriteLine("{0} {2} {1}", values(ctr), - restoredValues(ctr), - If(values(ctr).Equals(restoredValues(ctr)), "=", "<>")) - Next - - ' The example displays the following output on .NET Framework: - ' 2.882883 <> 2.882883 - ' 0.3333333 <> 0.3333333 - ' 3.141593 <> 3.141593 - ' - End Sub -End Module diff --git a/snippets/visualbasic/System/Single/Overview/comparison2.vb b/snippets/visualbasic/System/Single/Overview/comparison2.vb index d56467bdaa7..3f74f29eb87 100644 --- a/snippets/visualbasic/System/Single/Overview/comparison2.vb +++ b/snippets/visualbasic/System/Single/Overview/comparison2.vb @@ -11,10 +11,9 @@ Module Example2 Console.WriteLine("{0} = {1}: {2}", value1, value2, value1.Equals(value2)) - ' The example displays the following output on .NET: + ' The example displays the following output: ' 10.201438 = 10.201439: False - ' The example displays the following output on .NET Framework: - ' 10.20144 = 10.20144: False + ' End Sub End Module diff --git a/snippets/visualbasic/System/Single/Overview/precisionlist3.vb b/snippets/visualbasic/System/Single/Overview/precisionlist3.vb index c859ea1c29a..b5f439115f5 100644 --- a/snippets/visualbasic/System/Single/Overview/precisionlist3.vb +++ b/snippets/visualbasic/System/Single/Overview/precisionlist3.vb @@ -17,9 +17,9 @@ Module PrecisionList3 End If End Sub - ' The example displays the following output on .NET: + ' The example displays the following output: + ' The sum of the values (27.650002) does not equal the total (27.65). - ' The example displays the following output on .NET Framework: - ' The sum of the values (27.65) does not equal the total (27.65). + ' End Module diff --git a/snippets/visualbasic/System/String/IndexOf/ignorable21.vb b/snippets/visualbasic/System/String/IndexOf/ignorable21.vb index f81bc9531e0..2e903c98a9c 100644 --- a/snippets/visualbasic/System/String/IndexOf/ignorable21.vb +++ b/snippets/visualbasic/System/String/IndexOf/ignorable21.vb @@ -7,22 +7,21 @@ Module Example Dim softHyphen As String = ChrW(&h00AD) Dim s1 As String = "ani" + softHyphen + "mal" Dim s2 As String = "animal" - + ' Find the index of the soft hyphen. Console.WriteLine(s1.IndexOf(softHyphen)) Console.WriteLine(s2.IndexOf(softHyphen)) - + ' Find the index of the soft hyphen followed by "n". Console.WriteLine(s1.IndexOf(softHyphen + "n")) Console.WriteLine(s2.IndexOf(softHyphen + "n")) - + ' Find the index of the soft hyphen followed by "m". Console.WriteLine(s1.IndexOf(softHyphen + "m")) Console.WriteLine(s2.IndexOf(softHyphen + "m")) End Sub End Module -' The example displays the following output -' if run under the .NET Framework 4 or later: +' The example displays the following output: ' 0 ' 0 ' 1 diff --git a/snippets/visualbasic/System/TimeSpan/Parse/parsefailure1.vb b/snippets/visualbasic/System/TimeSpan/Parse/parsefailure1.vb index 9aeb188c916..d04cd1c8e6e 100644 --- a/snippets/visualbasic/System/TimeSpan/Parse/parsefailure1.vb +++ b/snippets/visualbasic/System/TimeSpan/Parse/parsefailure1.vb @@ -13,12 +13,9 @@ Module Example Console.WriteLine("{0}: Bad Format", value) Catch e As OverflowException Console.WriteLine("{0}: Overflow", value) - End Try + End Try Next - ' Output from .NET Framework 3.5 and earlier versions: - ' 000000006 --> 6.00:00:00 - ' 12.12:12:12.12345678: Bad Format - ' Output from .NET Framework 4: + ' Output: ' 000000006: Overflow ' 12.12:12:12.12345678: Overflow ' diff --git a/snippets/visualbasic/System/Type/Assembly/type_assembly.vb b/snippets/visualbasic/System/Type/Assembly/type_assembly.vb index f14d3b68369..8e7ec08b4e9 100644 --- a/snippets/visualbasic/System/Type/Assembly/type_assembly.vb +++ b/snippets/visualbasic/System/Type/Assembly/type_assembly.vb @@ -10,9 +10,12 @@ Class Example Console.WriteLine($"Assembly qualified name:{vbCrLf} {objType.AssemblyQualifiedName}.") End Sub End Class -' The example displays the following output if run under the .NET Framework 4.5: + +' The example displays output similar to the following: +' ' Assembly full name: -' mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089. +' System.Private.CoreLib, Version = 10.0.0.0, Culture = neutral, PublicKeyToken = 7cec85d7bea7798e. ' Assembly qualified name: -' System.Array, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089. + System.Array, System.Private.CoreLib, Version = 10.0.0.0, Culture = neutral, PublicKeyToken = 7cec85d7bea7798e. + ' diff --git a/xml/System.Runtime.Versioning/FrameworkName.xml b/xml/System.Runtime.Versioning/FrameworkName.xml index 6d82ced6dc4..00b05f44cbe 100644 --- a/xml/System.Runtime.Versioning/FrameworkName.xml +++ b/xml/System.Runtime.Versioning/FrameworkName.xml @@ -612,10 +612,11 @@ ## Remarks The method defines the operation of the equality operator for objects. - Languages that do not support custom operators can call the method instead. + Languages that don't support custom operators can call the method instead. ## Examples - The following example uses the equality operator to determine whether a object that represents the running version of .NET is equal to a supported version of .NET. Note that the two versions are not equal because they do not have identical version numbers. + +The following example uses the equality operator to determine whether a object that represents the running version of .NET is equal to a given version of .NET. Note that the two versions aren't equal because they don't have identical version numbers. :::code language="csharp" source="~/snippets/csharp/System.Runtime.Versioning/FrameworkName/op_Equality/Operators1.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/System.Runtime.Versioning/FrameworkName/op_Equality/Operators1.vb" id="Snippet1"::: diff --git a/xml/System.Windows/Application.xml b/xml/System.Windows/Application.xml index ea2aedb8888..13c390736f8 100644 --- a/xml/System.Windows/Application.xml +++ b/xml/System.Windows/Application.xml @@ -31,24 +31,20 @@ is a class that encapsulates WPF application-specific functionality, including the following: -- **Application Lifetime**: , , , , , , , , , . + is a class that encapsulates WPF application-specific functionality, including the following: -- **Application-Scope Window, Property, and Resource Management**: , , , , , , , , . - -- **Command-Line Parameter and Exit Code Processing**: , , . - -- **Navigation**: , , , , , , , , . +- **Application Lifetime**: , , , , , , , , , . +- **Application-Scope Window, Property, and Resource Management**: , , , , , , , , . +- **Command-Line Parameter and Exit Code Processing**: , , . +- **Navigation**: , , , , , , , , . implements the singleton pattern to provide shared access to its window, property, and resource scope services. Consequently, only one instance of the class can be created per . You can implement an using markup, markup and code-behind, or code. If is implemented with markup, whether markup or markup and code-behind, the markup file must be configured as an Microsoft build engine (MSBuild) `ApplicationDefinition` item. > [!NOTE] -> A standalone application does not require an object; it is possible to implement a custom `static` entry point method (`Main`) that opens a window without creating an instance of . However, XAML browser applications (XBAPs) require an object. - - +> A standalone application does not require an object; it's possible to implement a custom `static` entry point method (`Main`) that opens a window without creating an instance of . However, XAML browser applications (XBAPs) require an object. ## Examples The following example shows how a standard application is defined using only markup: diff --git a/xml/System/String.xml b/xml/System/String.xml index 12f6cced7d0..c0bc6f12311 100644 --- a/xml/System/String.xml +++ b/xml/System/String.xml @@ -7101,13 +7101,14 @@ Index numbering starts from zero. This method performs a word (case-sensitive and culture-sensitive) search using the current culture. The search begins at the first character position of this instance and continues until the last character position. -Character sets include ignorable characters, which are characters that are not considered when performing a linguistic or culture-sensitive comparison. In a culture-sensitive search, if `value` contains an ignorable character, the result is equivalent to searching with that character removed. If `value` consists only of one or more ignorable characters, the method always returns 0 (zero) to indicate that the match is found at the beginning of the current instance. In the following example, the method is used to find three substrings (a soft hyphen (U+00AD), a soft hyphen followed by "n", and a soft hyphen followed by "m") in two strings. Only one of the strings contains a soft hyphen. Because the soft hyphen is an ignorable character, the result is the same as if the soft hyphen had not been included in `value`. When searching for a soft hyphen only, the method returns 0 (zero) to indicate that it has found a match at the beginning of the string. +Character sets include ignorable characters, which are characters that aren't considered when performing a linguistic or culture-sensitive comparison. In a culture-sensitive search, if `value` contains an ignorable character, the result is equivalent to searching with that character removed. If `value` consists only of one or more ignorable characters, the method always returns 0 (zero) to indicate that the match is found at the beginning of the current instance. In the following example, the method is used to find three substrings (a soft hyphen (U+00AD), a soft hyphen followed by "n", and a soft hyphen followed by "m") in two strings. Only one of the strings contains a soft hyphen. Because the soft hyphen is an ignorable character, the result is the same as if the soft hyphen had not been included in `value`. When searching for a soft hyphen only, the method returns 0 (zero) to indicate that it has found a match at the beginning of the string. :::code language="csharp" source="~/snippets/csharp/System/String/IndexOf/ignorable21.cs" id="Snippet21"::: :::code language="fsharp" source="~/snippets/fsharp/System/String/IndexOf/ignorable21.fs" id="Snippet21"::: :::code language="vb" source="~/snippets/visualbasic/System/String/IndexOf/ignorable21.vb" id="Snippet21"::: ## Examples + The following example searches for the "n" in "animal". Because string indexes begin at zero rather than one, the method indicates that the "n" is at position 1. :::code language="csharp" source="~/snippets/csharp/System/String/IndexOf/simple1.cs" id="Snippet12"::: diff --git a/xml/System/Type.xml b/xml/System/Type.xml index f1af3125d80..02efa37e263 100644 --- a/xml/System/Type.xml +++ b/xml/System/Type.xml @@ -324,20 +324,21 @@ The code example uses the to invoke the property. + +The assembly-qualified name of a type consists of the type name, including its namespace, followed by a comma, followed by the display name of the assembly. The display name of an assembly is obtained using the property. > [!NOTE] > Processor architecture is part of assembly identity, and can be specified as part of assembly name strings. For example, "ProcessorArchitecture=msil". However, it's not included in the string returned by the property, for compatibility reasons. See . All compilers that support the common language runtime emit the simple name of a nested class, and reflection constructs a mangled name when queried, in accordance with the following conventions. -|Delimiter|Meaning| -|---------------|-------------| -|Backslash (\\)|Escape character.| -|Comma (,)|Precedes the Assembly name.| -|Plus sign (+)|Precedes a nested class.| -|Period (.)|Denotes namespace identifiers.| -|Brackets ([])|After a type name, denotes an array of that type.

-or-

For a generic type, encloses the generic type argument list.

-or-

Within a type argument list, encloses an assembly-qualified type.| +| Delimiter | Meaning | +|----------------|--------------------------------| +| Backslash (\\) | Escape character. | +| Comma (,) | Precedes the Assembly name. | +| Plus sign (+) | Precedes a nested class. | +| Period (.) | Denotes namespace identifiers. | +| Brackets ([]) | After a type name, denotes an array of that type.

-or-

For a generic type, encloses the generic type argument list.

-or-

Within a type argument list, encloses an assembly-qualified type. | For example, the assembly-qualified name for a class might look like this: @@ -364,7 +365,8 @@ TopNamespace.Sub\+Namespace.ContainingClass+NestedClass, MyAssembly, Version=1.3 If the current object represents a generic parameter, this property returns `null`. ## Examples - The following example displays the assembly name associated with the class and the fully qualified name of the type. + +The following example displays the assembly name associated with the class and the fully qualified name of the type. :::code language="csharp" source="~/snippets/csharp/System/Type/Assembly/type_assembly.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/Type/Assembly/type_assembly.fs" id="Snippet1"::: From dca246f0d76244cbec36231e4deadeeed28d985a Mon Sep 17 00:00:00 2001 From: Genevieve Warren <24882762+gewarren@users.noreply.github.com> Date: Fri, 31 Jul 2026 15:19:28 -0700 Subject: [PATCH 2/3] delete refs to deleted snippets --- .../ServerComputer.xml | 25 +- .../FileSystem.xml | 406 +----------------- .../SpecialDirectories.xml | 210 +++------ .../FileSystemProxy.xml | 312 +------------- .../SpecialDirectoriesProxy.xml | 206 +++------ 5 files changed, 165 insertions(+), 994 deletions(-) diff --git a/xml/Microsoft.VisualBasic.Devices/ServerComputer.xml b/xml/Microsoft.VisualBasic.Devices/ServerComputer.xml index 45d8d3fc24b..ad49227e469 100644 --- a/xml/Microsoft.VisualBasic.Devices/ServerComputer.xml +++ b/xml/Microsoft.VisualBasic.Devices/ServerComputer.xml @@ -214,22 +214,15 @@ ## Availability by Project Type -|Project type|Available| -|------------------|---------------| -|Windows Forms Application|**Yes**| -|Class Library|**Yes**| -|Console Application|**Yes**| -|Windows Forms Control Library|**Yes**| -|Web Control Library|**Yes**| -|Windows Service|**Yes**| -|Web Site|**Yes**| - - - -## Examples - This example checks to determine whether the folder `C:\backup\logs` exists and checks its properties. - - :::code language="vb" source="~/snippets/visualbasic/Microsoft.VisualBasic.Devices/ServerComputer/FileSystem/Class1.vb" id="Snippet23"::: +| Project type | Available | +|-------------------------------|-----------| +| Windows Forms Application | **Yes** | +| Class Library | **Yes** | +| Console Application | **Yes** | +| Windows Forms Control Library | **Yes** | +| Web Control Library | **Yes** | +| Windows Service | **Yes** | +| Web Site | **Yes** | ]]>
diff --git a/xml/Microsoft.VisualBasic.FileIO/FileSystem.xml b/xml/Microsoft.VisualBasic.FileIO/FileSystem.xml index 7b8845d1e48..4159ccaf5dd 100644 --- a/xml/Microsoft.VisualBasic.FileIO/FileSystem.xml +++ b/xml/Microsoft.VisualBasic.FileIO/FileSystem.xml @@ -68,13 +68,6 @@ |Read from the **MyDocuments** directory|[How to: Retrieve the Contents of the My Documents Directory](/dotnet/visual-basic/developing-apps/programming/drives-directories-files/how-to-retrieve-the-contents-of-the-my-documents-directory)| |Parse a file path|[How to: Parse File Paths](/dotnet/visual-basic/developing-apps/programming/drives-directories-files/how-to-parse-file-paths)| - - -## Examples - This example checks to determine whether the folder `C:\backup\logs` exists and checks its properties. - - :::code language="vb" source="~/snippets/visualbasic/Microsoft.VisualBasic.Devices/ServerComputer/FileSystem/Class1.vb" id="Snippet23"::: - ]]> @@ -230,20 +223,7 @@ When copying files within a directory, exceptions may be thrown that are caused by a specific file. When such exceptions are thrown, they are consolidated into a single exception whose `Data` property holds entries in the form of an in which the file or directory path is the key and the specific exception message is contained in the corresponding value. Use `For…Each` to enumerate through the entries. - The following table lists an example of a task involving the `My.Computer.FileSystem.CopyDirectory` method. - -|To|See| -|-|-| -|Copy a directory|[How to: Copy a Directory to Another Directory in Visual Basic](/dotnet/visual-basic/developing-apps/programming/drives-directories-files/how-to-copy-a-directory-to-another-directory)| - - - -## Examples - The following example copies the contents of directory `TestDirectory1` into `TestDirectory2`. - - :::code language="vb" source="~/snippets/visualbasic/Microsoft.VisualBasic.Devices/ServerComputer/FileSystem/Class1.vb" id="Snippet94"::: - - Replace `C:\TestDirectory1` and `C:\TestDirectory2` with the path and name of the directory you wish to copy and the location to which you wish to copy it. +To copy a directory, see [How to: Copy a Directory to Another Directory in Visual Basic](/dotnet/visual-basic/developing-apps/programming/drives-directories-files/how-to-copy-a-directory-to-another-directory). ]]> @@ -301,20 +281,7 @@ When copying files within a directory, exceptions may be thrown that are caused by a specific file. When such exceptions are thrown, they are consolidated into a single exception whose `Data` property holds entries in the form of an in which the file or directory path is the key and the specific exception message is contained in the corresponding value. Use `For…Each` to enumerate through the entries. - The following table lists an example of a task involving the `My.Computer.FileSystem.CopyDirectory` method. - -|To|See| -|-|-| -|Copy a directory|[How to: Copy a Directory to Another Directory in Visual Basic](/dotnet/visual-basic/developing-apps/programming/drives-directories-files/how-to-copy-a-directory-to-another-directory)| - - - -## Examples - The following example copies the contents of directory `TestDirectory1` into `TestDirectory2`, showing progress dialog and any error dialog. - - :::code language="vb" source="~/snippets/visualbasic/Microsoft.VisualBasic.Devices/ServerComputer/FileSystem/Class1.vb" id="Snippet92"::: - - Replace `C:\TestDirectory1` and `C:\TestDirectory2` with the path and name of the directory you wish to copy and the location to which you wish to copy it. +To copy a directory, see [How to: Copy a Directory to Another Directory in Visual Basic](/dotnet/visual-basic/developing-apps/programming/drives-directories-files/how-to-copy-a-directory-to-another-directory). ]]> @@ -375,20 +342,7 @@ When copying files within a directory, exceptions may be thrown that are caused by a specific file, such as a file existing during a merge while `overwrite` is set to `False`. When such exceptions are thrown, they are consolidated into a single exception whose `Data` property holds entries in the form of an in which the file or directory path is the key and the specific exception message is contained in the corresponding value. Use `For…Each` to enumerate through the entries. - The following table lists an example of a task involving the `My.Computer.FileSystem.CopyDirectory` method. - -|To|See| -|-|-| -|Copy a directory|[How to: Copy a Directory to Another Directory in Visual Basic](/dotnet/visual-basic/developing-apps/programming/drives-directories-files/how-to-copy-a-directory-to-another-directory)| - - - -## Examples - The following example copies the contents of directory `TestDirectory1` into `TestDirectory2`, overwriting existing files. - - :::code language="vb" source="~/snippets/visualbasic/Microsoft.VisualBasic.Devices/ServerComputer/FileSystem/Class1.vb" id="Snippet49"::: - - Replace `C:\TestDirectory1` and `C:\TestDirectory2` with the path and name of the directory you wish to copy and the location to which you wish to copy it. +To copy a directory, see [How to: Copy a Directory to Another Directory in Visual Basic](/dotnet/visual-basic/developing-apps/programming/drives-directories-files/how-to-copy-a-directory-to-another-directory). ]]> @@ -448,20 +402,7 @@ When copying files within a directory, exceptions may be thrown that are caused by a specific file. When such exceptions are thrown, they are consolidated into a single exception whose `Data` property holds entries in the form of an in which the file or directory path is the key and the specific exception message is contained in the corresponding value. Use `For…Each` to enumerate through the entries. - The following table lists an example of a task involving the `My.Computer.FileSystem.CopyDirectory` method. - -|To|See| -|-|-| -|Copy a directory|[How to: Copy a Directory to Another Directory in Visual Basic](/dotnet/visual-basic/developing-apps/programming/drives-directories-files/how-to-copy-a-directory-to-another-directory)| - - - -## Examples - The following example copies the contents of directory `TestDirectory1` into `TestDirectory2`, showing progress dialog and any error dialog, and does nothing if the user clicks **Cancel** during the operation. - - :::code language="vb" source="~/snippets/visualbasic/Microsoft.VisualBasic.Devices/ServerComputer/FileSystem/Class1.vb" id="Snippet93"::: - - Replace `C:\TestDirectory1` and `C:\TestDirectory2` with the path and name of the directory you wish to copy and the location to which you wish to copy it. +To copy a directory, see [How to: Copy a Directory to Another Directory in Visual Basic](/dotnet/visual-basic/developing-apps/programming/drives-directories-files/how-to-copy-a-directory-to-another-directory). ]]> @@ -827,18 +768,7 @@ ## Remarks If the directory already exists, no exception is thrown. - The following table lists an example of a task involving the `My.Computer.FileSystem.CreateDirectory` method. - -|To|See| -|-|-| -|Create a directory|[How to: Create a Directory in Visual Basic](/dotnet/visual-basic/developing-apps/programming/drives-directories-files/how-to-create-a-directory)| - - - -## Examples - This example creates the directory, `NewDirectory`, in `C:\Documents and Settings\All Users\Documents`. - - :::code language="vb" source="~/snippets/visualbasic/Microsoft.VisualBasic.Devices/ServerComputer/FileSystem/Class1.vb" id="Snippet17"::: +To create a directory, see [How to: Create a Directory in Visual Basic](/dotnet/visual-basic/developing-apps/programming/drives-directories-files/how-to-create-a-directory). ]]> @@ -884,17 +814,6 @@ ## Remarks `CurrentDirectory` is a system-wide environment variable. - - -## Examples - This example returns the current directory and displays it in a message box. - - :::code language="vb" source="~/snippets/visualbasic/Microsoft.VisualBasic.Devices/ServerComputer/FileSystem/Class1.vb" id="Snippet18"::: - - This example sets the current directory to `C:\TestDirectory`. - - :::code language="vb" source="~/snippets/visualbasic/Microsoft.VisualBasic.Devices/ServerComputer/FileSystem/Class1.vb" id="Snippet19"::: - ]]> The path is not valid. @@ -937,28 +856,7 @@ Directory to be deleted. Specifies what should be done when a directory that is to be deleted contains files or directories. Default is . Deletes a directory. - - - + To be added. The path is a zero-length string, is malformed, contains only white space, or contains invalid characters (including wildcard characters). The path is a device path (starts with \\\\.\\). is or an empty string. @@ -1010,25 +908,6 @@ ## Remarks The `showUI` and `recycle` parameters are not supported in applications that are not user interactive, such as Windows Services. - - -## Examples - The example deletes the directory `OldDirectory` only if it is empty. - - :::code language="vb" source="~/snippets/visualbasic/Microsoft.VisualBasic.Devices/ServerComputer/FileSystem/Class1.vb" id="Snippet56"::: - - This example deletes the directory `OldDirectory` and all of its contents. - - :::code language="vb" source="~/snippets/visualbasic/Microsoft.VisualBasic.Devices/ServerComputer/FileSystem/Class1.vb" id="Snippet57"::: - - This example deletes the directory `OldDirectory` and all of its contents, asking the user to confirm the deletion, but does not send the contents to the **Recycle Bin**. - - :::code language="vb" source="~/snippets/visualbasic/Microsoft.VisualBasic.Devices/ServerComputer/FileSystem/Class1.vb" id="Snippet58"::: - - This example deletes the directory `OldDirectory` and all of its contents, sending them to the **Recycle Bin**, but does not show the progress of the operation. - - :::code language="vb" source="~/snippets/visualbasic/Microsoft.VisualBasic.Devices/ServerComputer/FileSystem/Class1.vb" id="Snippet59"::: - ]]> The path is a zero-length string, is malformed, contains only white space, or contains invalid characters (including wildcard characters). The path is a device path (starts with \\\\.\\). @@ -1085,25 +964,6 @@ ## Remarks The `showUI`, `recycle`, and `onUserCancel` parameters are not supported in applications that are not user interactive, such as Windows Services. - - -## Examples - The example deletes the directory `OldDirectory` only if it is empty. - - :::code language="vb" source="~/snippets/visualbasic/Microsoft.VisualBasic.Devices/ServerComputer/FileSystem/Class1.vb" id="Snippet56"::: - - This example deletes the directory `OldDirectory` and all of its contents. - - :::code language="vb" source="~/snippets/visualbasic/Microsoft.VisualBasic.Devices/ServerComputer/FileSystem/Class1.vb" id="Snippet57"::: - - This example deletes the directory `OldDirectory` and all of its contents, asking the user to confirm the deletion, but does not send the contents to the **Recycle Bin**. - - :::code language="vb" source="~/snippets/visualbasic/Microsoft.VisualBasic.Devices/ServerComputer/FileSystem/Class1.vb" id="Snippet58"::: - - This example deletes the directory `OldDirectory` and all of its contents, sending them to the **Recycle Bin**, but does not show the progress of the operation. - - :::code language="vb" source="~/snippets/visualbasic/Microsoft.VisualBasic.Devices/ServerComputer/FileSystem/Class1.vb" id="Snippet59"::: - ]]> The path is a zero-length string, is malformed, contains only white space, or contains invalid characters (including wildcard characters). The path is a device path (starts with \\\\.\\). @@ -1157,27 +1017,7 @@ @@ -1231,26 +1071,7 @@ ## Remarks The `showUI` and `recycle` parameters are not supported in applications that are not user interactive, such as Windows Services. - The following table lists an example of a task involving the `My.Computer.FileSystem.DeleteFile` method. - -|To|See| -|-|-| -|To delete a file|[How to: Delete a File in Visual Basic](/dotnet/visual-basic/developing-apps/programming/drives-directories-files/how-to-delete-a-file)| - - - -## Examples - This example deletes the file `Test.txt`. - - :::code language="vb" source="~/snippets/visualbasic/Microsoft.VisualBasic.Devices/ServerComputer/FileSystem/Class1.vb" id="Snippet3"::: - - This example deletes the file `Test.txt` and allows the user to confirm that the file should be deleted. - - :::code language="vb" source="~/snippets/visualbasic/Microsoft.VisualBasic.Devices/ServerComputer/FileSystem/Class1.vb" id="Snippet4"::: - - This example deletes the file `Test.txt` and sends it to the **Recycle Bin**. - - :::code language="vb" source="~/snippets/visualbasic/Microsoft.VisualBasic.Devices/ServerComputer/FileSystem/Class1.vb" id="Snippet5"::: +To delete a file, see [How to: Delete a File in Visual Basic](/dotnet/visual-basic/developing-apps/programming/drives-directories-files/how-to-delete-a-file). ]]> @@ -1308,26 +1129,7 @@ ## Remarks The `showUI`, `recycle`, and `onUserCancel` parameters are not supported in applications that are not user interactive, such as Windows Services. - The following table lists an example of a task involving the `My.Computer.FileSystem.DeleteFile` method. - -|To|See| -|-|-| -|To delete a file|[How to: Delete a File in Visual Basic](/dotnet/visual-basic/developing-apps/programming/drives-directories-files/how-to-delete-a-file)| - - - -## Examples - This example deletes the file `Test.txt`. - - :::code language="vb" source="~/snippets/visualbasic/Microsoft.VisualBasic.Devices/ServerComputer/FileSystem/Class1.vb" id="Snippet3"::: - - This example deletes the file `Test.txt` and allows the user to confirm that the file should be deleted. - - :::code language="vb" source="~/snippets/visualbasic/Microsoft.VisualBasic.Devices/ServerComputer/FileSystem/Class1.vb" id="Snippet4"::: - - This example deletes the file `Test.txt` and sends it to the **Recycle Bin**. - - :::code language="vb" source="~/snippets/visualbasic/Microsoft.VisualBasic.Devices/ServerComputer/FileSystem/Class1.vb" id="Snippet5"::: +To delete a file, see [How to: Delete a File in Visual Basic](/dotnet/visual-basic/developing-apps/programming/drives-directories-files/how-to-delete-a-file). ]]> @@ -2165,20 +1967,7 @@ The `GetName` method ignores a slash mark occurring at the end of the path. - The following table lists an example of a task involving the `My.Computer.FileSystem.GetFileName` method. - -|To|See| -|-|-| -|Parse a file path|[How to: Parse File Paths in Visual Basic](/dotnet/visual-basic/developing-apps/programming/drives-directories-files/how-to-parse-file-paths)| - - - -## Examples - The following example parses a file path and returns the name of the file. - - :::code language="vb" source="~/snippets/visualbasic/Microsoft.VisualBasic.Devices/ServerComputer/FileSystem/Class1.vb" id="Snippet21"::: - - Replace the path `C:\Testdirectory\Testfile` with the path you wish to parse. +To parse a file path, see [How to: Parse File Paths in Visual Basic](/dotnet/visual-basic/developing-apps/programming/drives-directories-files/how-to-parse-file-paths). ]]> @@ -2270,13 +2059,6 @@ ## Remarks This method can be used to create a temporary file. - - -## Examples - This example creates a temp file and returns its path. - - :::code language="vb" source="~/snippets/visualbasic/Microsoft.VisualBasic.Devices/ServerComputer/FileSystem/Class1.vb" id="Snippet12"::: - ]]> @@ -2323,17 +2105,6 @@ ## Remarks If an attempt is made to move a directory inside a directory that does not exist, the target structure will be created. - - -## Examples - This example moves `Directory1` inside `Directory2`. - - :::code language="vb" source="~/snippets/visualbasic/Microsoft.VisualBasic.Devices/ServerComputer/FileSystem/Class1.vb" id="Snippet81"::: - - This example moves `Directory1` inside `Directory2`, overwriting the directory if it already exists. - - :::code language="vb" source="~/snippets/visualbasic/Microsoft.VisualBasic.Devices/ServerComputer/FileSystem/Class1.vb" id="Snippet82"::: - ]]> The path is not valid for one of the following reasons: it is a zero-length string; it contains only white space; it contains invalid characters; or it is a device path (starts with \\\\.\\). @@ -2389,17 +2160,6 @@ ## Remarks If an attempt is made to move a directory inside a directory that does not exist, the target structure will be created. - - -## Examples - This example moves `Directory1` inside `Directory2`. - - :::code language="vb" source="~/snippets/visualbasic/Microsoft.VisualBasic.Devices/ServerComputer/FileSystem/Class1.vb" id="Snippet81"::: - - This example moves `Directory1` inside `Directory2`, overwriting the directory if it already exists. - - :::code language="vb" source="~/snippets/visualbasic/Microsoft.VisualBasic.Devices/ServerComputer/FileSystem/Class1.vb" id="Snippet82"::: - ]]> The path is not valid for one of the following reasons: it is a zero-length string; it contains only white space; it contains invalid characters; or it is a device path (starts with \\\\.\\). @@ -2457,17 +2217,6 @@ ## Remarks If an attempt is made to move a directory inside a directory that does not exist, the target structure will be created. - - -## Examples - This example moves `Directory1` inside `Directory2`. - - :::code language="vb" source="~/snippets/visualbasic/Microsoft.VisualBasic.Devices/ServerComputer/FileSystem/Class1.vb" id="Snippet81"::: - - This example moves `Directory1` inside `Directory2`, overwriting the directory if it already exists. - - :::code language="vb" source="~/snippets/visualbasic/Microsoft.VisualBasic.Devices/ServerComputer/FileSystem/Class1.vb" id="Snippet82"::: - ]]> The path is not valid for one of the following reasons: it is a zero-length string; it contains only white space; it contains invalid characters; or it is a device path (starts with \\\\.\\). @@ -2525,17 +2274,6 @@ ## Remarks If an attempt is made to move a directory inside a directory that does not exist, the target structure will be created. - - -## Examples - This example moves `Directory1` inside `Directory2`. - - :::code language="vb" source="~/snippets/visualbasic/Microsoft.VisualBasic.Devices/ServerComputer/FileSystem/Class1.vb" id="Snippet81"::: - - This example moves `Directory1` inside `Directory2`, overwriting the directory if it already exists. - - :::code language="vb" source="~/snippets/visualbasic/Microsoft.VisualBasic.Devices/ServerComputer/FileSystem/Class1.vb" id="Snippet82"::: - ]]> The path is not valid for one of the following reasons: it is a zero-length string; it contains only white space; it contains invalid characters; or it is a device path (starts with \\\\.\\). @@ -2601,22 +2339,7 @@ The `MoveFile` method preserves ACEs (Access Control Entries) only when moving the file within the same volume. This includes inherited ACEs, which become direct ACEs when moved (direct ACEs take precedence over inherited ACEs). If a file is moved between volumes, ACEs will not be copied. - The following table lists an example of a task involving the `My.Computer.FileSystem.MoveFile` method. - -|To|See| -|-|-| -|Move a file|[How to: Move a File in Visual Basic](/dotnet/visual-basic/developing-apps/programming/drives-directories-files/how-to-move-a-file)| - - - -## Examples - This example moves the file `Test.txt` from `TestDir1` to `TestDir2`. - - :::code language="vb" source="~/snippets/visualbasic/Microsoft.VisualBasic.Devices/ServerComputer/FileSystem/Class1.vb" id="Snippet86"::: - - This example moves the file `Test.txt` from `TestDir1` to `TestDir2` and renames it `Test2.txt`. - - :::code language="vb" source="~/snippets/visualbasic/Microsoft.VisualBasic.Devices/ServerComputer/FileSystem/Class1.vb" id="Snippet87"::: +To move a file, see [How to: Move a File in Visual Basic](/dotnet/visual-basic/developing-apps/programming/drives-directories-files/how-to-move-a-file). ]]> @@ -2671,22 +2394,7 @@ The `MoveFile` method preserves ACEs (Access Control Entries) only when moving the file within the same volume. This includes inherited ACEs, which become direct ACEs when moved (direct ACEs take precedence over inherited ACEs). If a file is moved between volumes, ACEs will not be copied. - The following table lists an example of a task involving the `My.Computer.FileSystem.MoveFile` method. - -|To|See| -|-|-| -|Move a file|[How to: Move a File in Visual Basic](/dotnet/visual-basic/developing-apps/programming/drives-directories-files/how-to-move-a-file)| - - - -## Examples - This example moves the file `Test.txt` from `TestDir1` to `TestDir2`. - - :::code language="vb" source="~/snippets/visualbasic/Microsoft.VisualBasic.Devices/ServerComputer/FileSystem/Class1.vb" id="Snippet86"::: - - This example moves the file `Test.txt` from `TestDir1` to `TestDir2` and renames it `Test2.txt`. - - :::code language="vb" source="~/snippets/visualbasic/Microsoft.VisualBasic.Devices/ServerComputer/FileSystem/Class1.vb" id="Snippet87"::: +To move a file, see [How to: Move a File in Visual Basic](/dotnet/visual-basic/developing-apps/programming/drives-directories-files/how-to-move-a-file). ]]> @@ -2743,22 +2451,7 @@ The `MoveFile` method preserves ACEs (Access Control Entries) only when moving the file within the same volume. This includes inherited ACEs, which become direct ACEs when moved (direct ACEs take precedence over inherited ACEs). If a file is moved between volumes, ACEs will not be copied. - The following table lists an example of a task involving the `My.Computer.FileSystem.MoveFile` method. - -|To|See| -|-|-| -|Move a file|[How to: Move a File in Visual Basic](/dotnet/visual-basic/developing-apps/programming/drives-directories-files/how-to-move-a-file)| - - - -## Examples - This example moves the file `Test.txt` from `TestDir1` to `TestDir2`. - - :::code language="vb" source="~/snippets/visualbasic/Microsoft.VisualBasic.Devices/ServerComputer/FileSystem/Class1.vb" id="Snippet86"::: - - This example moves the file `Test.txt` from `TestDir1` to `TestDir2` and renames it `Test2.txt`. - - :::code language="vb" source="~/snippets/visualbasic/Microsoft.VisualBasic.Devices/ServerComputer/FileSystem/Class1.vb" id="Snippet87"::: +To move a file, see [How to: Move a File in Visual Basic](/dotnet/visual-basic/developing-apps/programming/drives-directories-files/how-to-move-a-file). ]]> @@ -2815,22 +2508,7 @@ The `MoveFile` method preserves ACEs (Access Control Entries) only when moving the file within the same volume. This includes inherited ACEs, which become direct ACEs when moved (direct ACEs take precedence over inherited ACEs). If a file is moved between volumes, ACEs will not be copied. - The following table lists an example of a task involving the `My.Computer.FileSystem.MoveFile` method. - -|To|See| -|-|-| -|Move a file|[How to: Move a File in Visual Basic](/dotnet/visual-basic/developing-apps/programming/drives-directories-files/how-to-move-a-file)| - - - -## Examples - This example moves the file `Test.txt` from `TestDir1` to `TestDir2`. - - :::code language="vb" source="~/snippets/visualbasic/Microsoft.VisualBasic.Devices/ServerComputer/FileSystem/Class1.vb" id="Snippet86"::: - - This example moves the file `Test.txt` from `TestDir1` to `TestDir2` and renames it `Test2.txt`. - - :::code language="vb" source="~/snippets/visualbasic/Microsoft.VisualBasic.Devices/ServerComputer/FileSystem/Class1.vb" id="Snippet87"::: +To move a file, see [How to: Move a File in Visual Basic](/dotnet/visual-basic/developing-apps/programming/drives-directories-files/how-to-move-a-file). ]]> @@ -3368,18 +3046,7 @@ Do not make decisions about the contents of the file based on the name of the file. For example, the file Form1.vb may not be a Visual Basic source file. Verify all inputs before using the data in your application. - The following table lists an example of a task involving the `My.Computer.FileSystem.ReadAllBytes` method. - -|To|See| -|-|-| -|Read from a binary file|[How to: Read From Binary Files in Visual Basic](/dotnet/visual-basic/developing-apps/programming/drives-directories-files/how-to-read-from-binary-files)| - - - -## Examples - This example reads from the file `C:/Documents and Settings/selfportrait.jpg.` - - :::code language="vb" source="~/snippets/visualbasic/Microsoft.VisualBasic.Devices/ServerComputer/FileSystem/Class1.vb" id="Snippet33"::: +To read from a binary file, see [How to: Read From Binary Files in Visual Basic](/dotnet/visual-basic/developing-apps/programming/drives-directories-files/how-to-read-from-binary-files). ]]> @@ -3516,13 +3183,7 @@ Do not make decisions about the contents of the file based on the name of the file. For example, the file Form1.vb may not be a Visual Basic source file. Verify all inputs before using the data in your application. - The following table lists an example of a task involving the `My.Computer.FileSystem.ReadAllText` method. - -|To|See| -|-|-| -|Read from a text file|[How to: Read From Text Files in Visual Basic](/dotnet/visual-basic/developing-apps/programming/drives-directories-files/how-to-read-from-text-files)| - - +To read from a text file, see [How to: Read From Text Files in Visual Basic](/dotnet/visual-basic/developing-apps/programming/drives-directories-files/how-to-read-from-text-files). ## Examples This example reads the contents of `Test.txt` into a string and then displays it in a message box. @@ -3585,13 +3246,6 @@ ## Remarks This method cannot be used to move a directory; use the `MoveDirectory` method to move and rename the directory. - - -## Examples - This example renames the `Test` directory to `SecondTest`. - - :::code language="vb" source="~/snippets/visualbasic/Microsoft.VisualBasic.Devices/ServerComputer/FileSystem/Class1.vb" id="Snippet13"::: - ]]> @@ -3648,20 +3302,7 @@ ## Remarks This method cannot be used to move a file; use the method to move and rename the file. - The following table lists an example of a task involving the `My.Computer.FileSystem.RenameFile` method. - -|To|See| -|-|-| -|Rename a file|[How to: Rename a File in Visual Basic](/dotnet/visual-basic/developing-apps/programming/drives-directories-files/how-to-rename-a-file)| - - - -## Examples - This example renames the file `Test.txt` to `SecondTest.txt`. - - :::code language="vb" source="~/snippets/visualbasic/Microsoft.VisualBasic.Devices/ServerComputer/FileSystem/Class1.vb" id="Snippet1"::: - - Change "`C:\Test.txt`" to the path and file name of the file that you want to rename. +To rename a file, see [How to: Rename a File in Visual Basic](/dotnet/visual-basic/developing-apps/programming/drives-directories-files/how-to-rename-a-file). ]]> @@ -3724,18 +3365,7 @@ > [!NOTE] > The `WriteAllBytes` method opens a file, writes to it, and then closes it. Code that uses the `WriteAllBytes` method is simpler than code that uses a object. However, if you are adding data to a file using a loop, a object can provide better performance because you only have to open and close the file once. - The following table lists an example of a task involving the `My.Computer.FileSystem.WriteAllBytes` method. - -|To|See| -|-|-| -|Write to a binary file|[How to: Write to Binary Files in Visual Basic](/dotnet/visual-basic/developing-apps/programming/drives-directories-files/how-to-write-to-binary-files)| - - - -## Examples - This example appends the data array `CustomerData` to the file `CollectedData`. - - :::code language="vb" source="~/snippets/visualbasic/Microsoft.VisualBasic.Devices/ServerComputer/FileSystem/Class1.vb" id="Snippet50"::: +To write to a binary file, see [How to: Write to Binary Files in Visual Basic](/dotnet/visual-basic/developing-apps/programming/drives-directories-files/how-to-write-to-binary-files). ]]> diff --git a/xml/Microsoft.VisualBasic.FileIO/SpecialDirectories.xml b/xml/Microsoft.VisualBasic.FileIO/SpecialDirectories.xml index 1ad6d763761..d7e53468f8a 100644 --- a/xml/Microsoft.VisualBasic.FileIO/SpecialDirectories.xml +++ b/xml/Microsoft.VisualBasic.FileIO/SpecialDirectories.xml @@ -35,38 +35,31 @@ Provides properties for accessing commonly referenced directories. - exception is thrown. - - No backslash (\\) appears at the end of the path. - - The following table lists examples of tasks involving the `My.Computer.FileSystem.SpecialDirectories` object. - -|To|See| -|-|-| -|Read from the MyDocuments directory|[How to: Retrieve the Contents of the My Documents Directory](/dotnet/visual-basic/developing-apps/programming/drives-directories-files/how-to-retrieve-the-contents-of-the-my-documents-directory)| - -## Availability by Project Type - -|Project type|Available| -|-|-| -|Windows Application|**Yes**| -|Class Library|**Yes**| -|Console Application|**Yes**| -|Windows Control Library|**Yes**| -|Web Control Library|**Yes**| -|Windows Service|**Yes**| -|Web Site|**Yes**| - - - -## Examples - This example returns the `filePath` for the user's Desktop directory and displays it. - - :::code language="vb" source="~/snippets/visualbasic/Microsoft.VisualBasic.Devices/ServerComputer/FileSystem/Class1.vb" id="Snippet80"::: - + exception is thrown. + + No backslash (\\) appears at the end of the path. + + The following table lists examples of tasks involving the `My.Computer.FileSystem.SpecialDirectories` object. + +|To|See| +|-|-| +|Read from the MyDocuments directory|[How to: Retrieve the Contents of the My Documents Directory](/dotnet/visual-basic/developing-apps/programming/drives-directories-files/how-to-retrieve-the-contents-of-the-my-documents-directory)| + +## Availability by Project Type + +| Project type | Available | +|-------------------------|-----------| +| Windows Application | **Yes** | +| Class Library | **Yes** | +| Console Application | **Yes** | +| Windows Control Library | **Yes** | +| Web Control Library | **Yes** | +| Windows Service | **Yes** | +| Web Site | **Yes** | + ]]> @@ -127,18 +120,11 @@ Gets a path name pointing to the Application Data directory for the all users. The path to the Application Data directory for the all users. - . - - :::code language="vb" source="~/snippets/visualbasic/Microsoft.VisualBasic.Devices/ServerComputer/FileSystem/Class1.vb" id="Snippet79"::: - + Controls access to system and user environment variables. Associated enumeration: . @@ -174,18 +160,11 @@ Gets a path name pointing to the Application Data directory for the current user. The path to the Application Data directory for the current user. - . - - :::code language="vb" source="~/snippets/visualbasic/Microsoft.VisualBasic.Devices/ServerComputer/FileSystem/Class1.vb" id="Snippet48"::: - + The path is empty, usually because the operating system does not support the directory. @@ -220,18 +199,11 @@ Gets a path name pointing to the Desktop directory. The path to the Desktop directory. - . - - :::code language="vb" source="~/snippets/visualbasic/Microsoft.VisualBasic.Devices/ServerComputer/FileSystem/Class1.vb" id="Snippet60"::: - + The path is empty, usually because the operating system does not support the directory. @@ -266,18 +238,11 @@ Gets a path name pointing to the My Documents directory. The path to the My Documents directory. - . - - :::code language="vb" source="~/snippets/visualbasic/Microsoft.VisualBasic.Devices/ServerComputer/FileSystem/Class1.vb" id="Snippet53"::: - + The path is empty, usually because the operating system does not support the directory. @@ -312,18 +277,11 @@ Gets a path name pointing to the My Music directory. The path to the My Music directory. - . - - :::code language="vb" source="~/snippets/visualbasic/Microsoft.VisualBasic.Devices/ServerComputer/FileSystem/Class1.vb" id="Snippet26"::: - + The path is empty, usually because the operating system does not support the directory. @@ -358,18 +316,11 @@ Gets a path name pointing to the My Pictures directory. The path to the My Pictures directory. - . - - :::code language="vb" source="~/snippets/visualbasic/Microsoft.VisualBasic.Devices/ServerComputer/FileSystem/Class1.vb" id="Snippet77"::: - + The path is empty, usually because the operating system does not support the directory. @@ -404,18 +355,11 @@ Gets a path pointing to the **Program Files** directory. The path to the **Program Files** directory. - . - - :::code language="vb" source="~/snippets/visualbasic/Microsoft.VisualBasic.Devices/ServerComputer/FileSystem/Class1.vb" id="Snippet90"::: - + The path is empty, usually because the operating system does not support the directory. @@ -450,18 +394,11 @@ Gets a path name pointing to the Programs directory. The path to the Programs directory. - . - - :::code language="vb" source="~/snippets/visualbasic/Microsoft.VisualBasic.Devices/ServerComputer/FileSystem/Class1.vb" id="Snippet61"::: - + The path is empty, usually because the operating system does not support the directory. @@ -496,18 +433,11 @@ Gets a path name pointing to the Temp directory. The path to the Temp directory. - . - - :::code language="vb" source="~/snippets/visualbasic/Microsoft.VisualBasic.Devices/ServerComputer/FileSystem/Class1.vb" id="Snippet31"::: - + The path is empty, usually because the operating system does not support the directory. diff --git a/xml/Microsoft.VisualBasic.MyServices/FileSystemProxy.xml b/xml/Microsoft.VisualBasic.MyServices/FileSystemProxy.xml index a464ab35965..f6705b9843b 100644 --- a/xml/Microsoft.VisualBasic.MyServices/FileSystemProxy.xml +++ b/xml/Microsoft.VisualBasic.MyServices/FileSystemProxy.xml @@ -70,13 +70,6 @@ |Read from the **MyDocuments** directory|[How to: Retrieve the Contents of the My Documents Directory](/dotnet/visual-basic/developing-apps/programming/drives-directories-files/how-to-retrieve-the-contents-of-the-my-documents-directory)| |Parse a file path|[How to: Parse File Paths](/dotnet/visual-basic/developing-apps/programming/drives-directories-files/how-to-parse-file-paths)| - - -## Examples - This example checks to determine whether the folder `C:\backup\logs` exists and checks its properties. - - :::code language="vb" source="~/snippets/visualbasic/Microsoft.VisualBasic.Devices/ServerComputer/FileSystem/Class1.vb" id="Snippet23"::: - ]]> @@ -216,15 +209,6 @@ |--------|---------| |Copy a directory|[How to: Copy a Directory to Another Directory](/dotnet/visual-basic/developing-apps/programming/drives-directories-files/how-to-copy-a-directory-to-another-directory)| - - -## Examples - The following example copies the directory `TestDirectory1` into `TestDirectory2`, overwriting existing files. - - :::code language="vb" source="~/snippets/visualbasic/Microsoft.VisualBasic.Devices/ServerComputer/FileSystem/Class1.vb" id="Snippet49"::: - - Replace `C:\TestDirectory1` and `C:\TestDirectory2` with the path and name of the directory you wish to copy and the location to which you wish to copy it. - ]]> The path is not valid for one of the following reasons: it is a zero-length string; it contains only white space; it contains invalid characters; or it is a device path (starts with \\\\.\\). @@ -297,15 +281,6 @@ |--------|---------| |Copy a directory|[How to: Copy a Directory to Another Directory](/dotnet/visual-basic/developing-apps/programming/drives-directories-files/how-to-copy-a-directory-to-another-directory)| - - -## Examples - The following example copies the directory `TestDirectory1` into `TestDirectory2`, overwriting existing files. - - :::code language="vb" source="~/snippets/visualbasic/Microsoft.VisualBasic.Devices/ServerComputer/FileSystem/Class1.vb" id="Snippet49"::: - - Replace `C:\TestDirectory1` and `C:\TestDirectory2` with the path and name of the directory you wish to copy and the location to which you wish to copy it. - ]]> The path is not valid for one of the following reasons: it is a zero-length string; it contains only white space; it contains invalid characters; or it is a device path (starts with \\\\.\\). @@ -381,15 +356,6 @@ |--------|---------| |Copy a directory|[How to: Copy a Directory to Another Directory](/dotnet/visual-basic/developing-apps/programming/drives-directories-files/how-to-copy-a-directory-to-another-directory)| - - -## Examples - The following example copies the directory `TestDirectory1` into `TestDirectory2`, overwriting existing files. - - :::code language="vb" source="~/snippets/visualbasic/Microsoft.VisualBasic.Devices/ServerComputer/FileSystem/Class1.vb" id="Snippet49"::: - - Replace `C:\TestDirectory1` and `C:\TestDirectory2` with the path and name of the directory you wish to copy and the location to which you wish to copy it. - ]]> The path is not valid for one of the following reasons: it is a zero-length string; it contains only white space; it contains invalid characters; or it is a device path (starts with \\\\.\\). @@ -464,15 +430,6 @@ |--------|---------| |Copy a directory|[How to: Copy a Directory to Another Directory](/dotnet/visual-basic/developing-apps/programming/drives-directories-files/how-to-copy-a-directory-to-another-directory)| - - -## Examples - The following example copies the directory `TestDirectory1` into `TestDirectory2`, overwriting existing files. - - :::code language="vb" source="~/snippets/visualbasic/Microsoft.VisualBasic.Devices/ServerComputer/FileSystem/Class1.vb" id="Snippet49"::: - - Replace `C:\TestDirectory1` and `C:\TestDirectory2` with the path and name of the directory you wish to copy and the location to which you wish to copy it. - ]]> The path is not valid for one of the following reasons: it is a zero-length string; it contains only white space; it contains invalid characters; or it is a device path (starts with \\\\.\\). @@ -906,13 +863,6 @@ |--------|---------| |Create a directory|[How to: Create a Directory](/dotnet/visual-basic/developing-apps/programming/drives-directories-files/how-to-create-a-directory)| - - -## Examples - This example creates the directory, `NewDirectory`, in `C:\Documents and Settings\All Users\Documents`. - - :::code language="vb" source="~/snippets/visualbasic/Microsoft.VisualBasic.Devices/ServerComputer/FileSystem/Class1.vb" id="Snippet17"::: - ]]> The directory name is malformed. For example, it contains illegal characters or is only white space. @@ -965,17 +915,6 @@ ## Remarks `CurrentDirectory` is a system-wide environment variable. - - -## Examples - This example returns the current directory and displays it in a message box. - - :::code language="vb" source="~/snippets/visualbasic/Microsoft.VisualBasic.Devices/ServerComputer/FileSystem/Class1.vb" id="Snippet18"::: - - This example sets the current directory to `C:\TestDirectory`. - - :::code language="vb" source="~/snippets/visualbasic/Microsoft.VisualBasic.Devices/ServerComputer/FileSystem/Class1.vb" id="Snippet19"::: - ]]> The path is not valid. @@ -1026,28 +965,7 @@ Directory to be deleted. Specifies what should be done when a directory that is to be deleted contains files or directories. Default is . Deletes a directory. - - - + To be added. The path is a zero-length string, is malformed, contains only white space, or contains invalid characters (including wildcard characters). The path is a device path (starts with \\\\.\\). is or an empty string. @@ -1108,25 +1026,6 @@ ## Remarks The `showUI` and `recycle` parameters are not supported in applications that are not user interactive, such as Windows Services. - - -## Examples - The example deletes the directory `OldDirectory` only if it is empty. - - :::code language="vb" source="~/snippets/visualbasic/Microsoft.VisualBasic.Devices/ServerComputer/FileSystem/Class1.vb" id="Snippet56"::: - - This example deletes the directory `OldDirectory` and all of its contents. - - :::code language="vb" source="~/snippets/visualbasic/Microsoft.VisualBasic.Devices/ServerComputer/FileSystem/Class1.vb" id="Snippet57"::: - - This example deletes the directory `OldDirectory` and all of its contents, asking the user to confirm the deletion, but does not send the contents to the **Recycle Bin**. - - :::code language="vb" source="~/snippets/visualbasic/Microsoft.VisualBasic.Devices/ServerComputer/FileSystem/Class1.vb" id="Snippet58"::: - - This example deletes the directory `OldDirectory` and all of its contents, sending them to the **Recycle Bin**, but does not show the progress of the operation. - - :::code language="vb" source="~/snippets/visualbasic/Microsoft.VisualBasic.Devices/ServerComputer/FileSystem/Class1.vb" id="Snippet59"::: - ]]> The path is a zero-length string, is malformed, contains only white space, or contains invalid characters (including wildcard characters). The path is a device path (starts with \\\\.\\). @@ -1192,25 +1091,6 @@ ## Remarks The `showUI`, `recycle`, and `onUserCancel` parameters are not supported in applications that are not user interactive, such as Windows Services. - - -## Examples - The example deletes the directory `OldDirectory` only if it is empty. - - :::code language="vb" source="~/snippets/visualbasic/Microsoft.VisualBasic.Devices/ServerComputer/FileSystem/Class1.vb" id="Snippet56"::: - - This example deletes the directory `OldDirectory` and all of its contents. - - :::code language="vb" source="~/snippets/visualbasic/Microsoft.VisualBasic.Devices/ServerComputer/FileSystem/Class1.vb" id="Snippet57"::: - - This example deletes the directory `OldDirectory` and all of its contents, asking the user to confirm the deletion, but does not send the contents to the **Recycle Bin**. - - :::code language="vb" source="~/snippets/visualbasic/Microsoft.VisualBasic.Devices/ServerComputer/FileSystem/Class1.vb" id="Snippet58"::: - - This example deletes the directory `OldDirectory` and all of its contents, sending them to the **Recycle Bin**, but does not show the progress of the operation. - - :::code language="vb" source="~/snippets/visualbasic/Microsoft.VisualBasic.Devices/ServerComputer/FileSystem/Class1.vb" id="Snippet59"::: - ]]> The path is a zero-length string, is malformed, contains only white space, or contains invalid characters (including wildcard characters). The path is a device path (starts with \\\\.\\). @@ -1280,21 +1160,6 @@ |--------|---------| |To delete a file|[How to: Delete a File](/dotnet/visual-basic/developing-apps/programming/drives-directories-files/how-to-delete-a-file)| - - -## Examples - This example deletes the file `Test.txt`. - - :::code language="vb" source="~/snippets/visualbasic/Microsoft.VisualBasic.Devices/ServerComputer/FileSystem/Class1.vb" id="Snippet3"::: - - This example deletes the file `Test.txt` and allows the user to confirm that the file should be deleted. - - :::code language="vb" source="~/snippets/visualbasic/Microsoft.VisualBasic.Devices/ServerComputer/FileSystem/Class1.vb" id="Snippet4"::: - - This example deletes the file `Test.txt` and sends it to the **Recycle Bin**. - - :::code language="vb" source="~/snippets/visualbasic/Microsoft.VisualBasic.Devices/ServerComputer/FileSystem/Class1.vb" id="Snippet5"::: - ]]> The path is not valid for one of the following reasons: it is a zero-length string; it contains only white space; it contains invalid characters; it has a trailing slash where a file must be specified; or it is a device path (starts with \\\\.\\). @@ -1362,21 +1227,6 @@ |--------|---------| |To delete a file|[How to: Delete a File](/dotnet/visual-basic/developing-apps/programming/drives-directories-files/how-to-delete-a-file)| - - -## Examples - This example deletes the file `Test.txt`. - - :::code language="vb" source="~/snippets/visualbasic/Microsoft.VisualBasic.Devices/ServerComputer/FileSystem/Class1.vb" id="Snippet3"::: - - This example deletes the file `Test.txt` and allows the user to confirm that the file should be deleted. - - :::code language="vb" source="~/snippets/visualbasic/Microsoft.VisualBasic.Devices/ServerComputer/FileSystem/Class1.vb" id="Snippet4"::: - - This example deletes the file `Test.txt` and sends it to the **Recycle Bin**. - - :::code language="vb" source="~/snippets/visualbasic/Microsoft.VisualBasic.Devices/ServerComputer/FileSystem/Class1.vb" id="Snippet5"::: - ]]> The path is not valid for one of the following reasons: it is a zero-length string; it contains only white space; it contains invalid characters; it has a trailing slash where a file must be specified; or it is a device path (starts with \\\\.\\). @@ -1448,21 +1298,6 @@ |--------|---------| |To delete a file|[How to: Delete a File](/dotnet/visual-basic/developing-apps/programming/drives-directories-files/how-to-delete-a-file)| - - -## Examples - This example deletes the file `Test.txt`. - - :::code language="vb" source="~/snippets/visualbasic/Microsoft.VisualBasic.Devices/ServerComputer/FileSystem/Class1.vb" id="Snippet3"::: - - This example deletes the file `Test.txt` and allows the user to confirm that the file should be deleted. - - :::code language="vb" source="~/snippets/visualbasic/Microsoft.VisualBasic.Devices/ServerComputer/FileSystem/Class1.vb" id="Snippet4"::: - - This example deletes the file `Test.txt` and sends it to the **Recycle Bin**. - - :::code language="vb" source="~/snippets/visualbasic/Microsoft.VisualBasic.Devices/ServerComputer/FileSystem/Class1.vb" id="Snippet5"::: - ]]> The path is not valid for one of the following reasons: it is a zero-length string; it contains only white space; it contains invalid characters; it has a trailing slash where a file must be specified; or it is a device path (starts with \\\\.\\). @@ -2421,15 +2256,6 @@ |--------|---------| |Parse a file path|[How to: Parse File Paths](/dotnet/visual-basic/developing-apps/programming/drives-directories-files/how-to-parse-file-paths)| - - -## Examples - The following example parses a file path and returns the name of the file. - - :::code language="vb" source="~/snippets/visualbasic/Microsoft.VisualBasic.Devices/ServerComputer/FileSystem/Class1.vb" id="Snippet21"::: - - Replace the path `C:\Testdirectory\Testfile` with the path you wish to parse. - ]]> Objects (Visual Basic) @@ -2537,13 +2363,6 @@ ## Remarks This method can be used to create a temporary file. - - -## Examples - This example creates a temp file and returns its path. - - :::code language="vb" source="~/snippets/visualbasic/Microsoft.VisualBasic.Devices/ServerComputer/FileSystem/Class1.vb" id="Snippet12"::: - ]]> Objects (Visual Basic) @@ -2599,17 +2418,6 @@ ## Remarks If an attempt is made to move a directory inside a directory that does not exist, the target structure will be created. - - -## Examples - This example moves `Directory1` inside `Directory2`. - - :::code language="vb" source="~/snippets/visualbasic/Microsoft.VisualBasic.Devices/ServerComputer/FileSystem/Class1.vb" id="Snippet81"::: - - This example moves `Directory1` inside `Directory2`, overwriting the directory if it already exists. - - :::code language="vb" source="~/snippets/visualbasic/Microsoft.VisualBasic.Devices/ServerComputer/FileSystem/Class1.vb" id="Snippet82"::: - ]]> The path is not valid for one of the following reasons: it is a zero-length string; it contains only white space; it contains invalid characters; or it is a device path (starts with \\\\.\\). @@ -2674,17 +2482,6 @@ ## Remarks If an attempt is made to move a directory inside a directory that does not exist, the target structure will be created. - - -## Examples - This example moves `Directory1` inside `Directory2`. - - :::code language="vb" source="~/snippets/visualbasic/Microsoft.VisualBasic.Devices/ServerComputer/FileSystem/Class1.vb" id="Snippet81"::: - - This example moves `Directory1` inside `Directory2`, overwriting the directory if it already exists. - - :::code language="vb" source="~/snippets/visualbasic/Microsoft.VisualBasic.Devices/ServerComputer/FileSystem/Class1.vb" id="Snippet82"::: - ]]> The path is not valid for one of the following reasons: it is a zero-length string; it contains only white space; it contains invalid characters; or it is a device path (starts with \\\\.\\). @@ -2751,17 +2548,6 @@ ## Remarks If an attempt is made to move a directory inside a directory that does not exist, the target structure will be created. - - -## Examples - This example moves `Directory1` inside `Directory2`. - - :::code language="vb" source="~/snippets/visualbasic/Microsoft.VisualBasic.Devices/ServerComputer/FileSystem/Class1.vb" id="Snippet81"::: - - This example moves `Directory1` inside `Directory2`, overwriting the directory if it already exists. - - :::code language="vb" source="~/snippets/visualbasic/Microsoft.VisualBasic.Devices/ServerComputer/FileSystem/Class1.vb" id="Snippet82"::: - ]]> The path is not valid for one of the following reasons: it is a zero-length string; it contains only white space; it contains invalid characters; or it is a device path (starts with \\\\.\\). @@ -2828,17 +2614,6 @@ ## Remarks If an attempt is made to move a directory inside a directory that does not exist, the target structure will be created. - - -## Examples - This example moves `Directory1` inside `Directory2`. - - :::code language="vb" source="~/snippets/visualbasic/Microsoft.VisualBasic.Devices/ServerComputer/FileSystem/Class1.vb" id="Snippet81"::: - - This example moves `Directory1` inside `Directory2`, overwriting the directory if it already exists. - - :::code language="vb" source="~/snippets/visualbasic/Microsoft.VisualBasic.Devices/ServerComputer/FileSystem/Class1.vb" id="Snippet82"::: - ]]> The path is not valid for one of the following reasons: it is a zero-length string; it contains only white space; it contains invalid characters; or it is a device path (starts with \\\\.\\). @@ -2919,17 +2694,6 @@ |--------|---------| |Move a file|[How to: Move a File](/dotnet/visual-basic/developing-apps/programming/drives-directories-files/how-to-move-a-file)| - - -## Examples - This example moves the file `Test.txt` from `TestDir1` to `TestDir2`. - - :::code language="vb" source="~/snippets/visualbasic/Microsoft.VisualBasic.Devices/ServerComputer/FileSystem/Class1.vb" id="Snippet86"::: - - This example moves the file `Test.txt` from `TestDir1` to `TestDir2` and renames it `Test2.txt`. - - :::code language="vb" source="~/snippets/visualbasic/Microsoft.VisualBasic.Devices/ServerComputer/FileSystem/Class1.vb" id="Snippet87"::: - ]]> The path is not valid for one of the following reasons: it is a zero-length string; it contains only white space; it contains invalid characters; or it is a device path (starts with \\\\.\\); it ends with a trailing slash. @@ -2998,17 +2762,6 @@ |--------|---------| |Move a file|[How to: Move a File](/dotnet/visual-basic/developing-apps/programming/drives-directories-files/how-to-move-a-file)| - - -## Examples - This example moves the file `Test.txt` from `TestDir1` to `TestDir2`. - - :::code language="vb" source="~/snippets/visualbasic/Microsoft.VisualBasic.Devices/ServerComputer/FileSystem/Class1.vb" id="Snippet86"::: - - This example moves the file `Test.txt` from `TestDir1` to `TestDir2` and renames it `Test2.txt`. - - :::code language="vb" source="~/snippets/visualbasic/Microsoft.VisualBasic.Devices/ServerComputer/FileSystem/Class1.vb" id="Snippet87"::: - ]]> The path is not valid for one of the following reasons: it is a zero-length string; it contains only white space; it contains invalid characters; or it is a device path (starts with \\\\.\\); it ends with a trailing slash. @@ -3079,17 +2832,6 @@ |--------|---------| |Move a file|[How to: Move a File](/dotnet/visual-basic/developing-apps/programming/drives-directories-files/how-to-move-a-file)| - - -## Examples - This example moves the file `Test.txt` from `TestDir1` to `TestDir2`. - - :::code language="vb" source="~/snippets/visualbasic/Microsoft.VisualBasic.Devices/ServerComputer/FileSystem/Class1.vb" id="Snippet86"::: - - This example moves the file `Test.txt` from `TestDir1` to `TestDir2` and renames it `Test2.txt`. - - :::code language="vb" source="~/snippets/visualbasic/Microsoft.VisualBasic.Devices/ServerComputer/FileSystem/Class1.vb" id="Snippet87"::: - ]]> The path is not valid for one of the following reasons: it is a zero-length string; it contains only white space; it contains invalid characters; or it is a device path (starts with \\\\.\\); it ends with a trailing slash. @@ -3160,17 +2902,6 @@ |--------|---------| |Move a file|[How to: Move a File](/dotnet/visual-basic/developing-apps/programming/drives-directories-files/how-to-move-a-file)| - - -## Examples - This example moves the file `Test.txt` from `TestDir1` to `TestDir2`. - - :::code language="vb" source="~/snippets/visualbasic/Microsoft.VisualBasic.Devices/ServerComputer/FileSystem/Class1.vb" id="Snippet86"::: - - This example moves the file `Test.txt` from `TestDir1` to `TestDir2` and renames it `Test2.txt`. - - :::code language="vb" source="~/snippets/visualbasic/Microsoft.VisualBasic.Devices/ServerComputer/FileSystem/Class1.vb" id="Snippet87"::: - ]]> The path is not valid for one of the following reasons: it is a zero-length string; it contains only white space; it contains invalid characters; or it is a device path (starts with \\\\.\\); it ends with a trailing slash. @@ -3794,13 +3525,6 @@ |--------|---------| |Read from a binary file|[How to: Read From Binary Files](/dotnet/visual-basic/developing-apps/programming/drives-directories-files/how-to-read-from-binary-files)| - - -## Examples - This example reads from the file `C:/Documents and Settings/selfportrait.jpg.` - - :::code language="vb" source="~/snippets/visualbasic/Microsoft.VisualBasic.Devices/ServerComputer/FileSystem/Class1.vb" id="Snippet33"::: - ]]> The path is not valid for one of the following reasons: it is a zero-length string; it contains only white space; it contains invalid characters; or it is a device path (starts with \\\\.\\); it ends with a trailing slash. @@ -4040,13 +3764,6 @@ ## Remarks This method cannot be used to move a directory; use the `MoveDirectory` method to move and rename the directory. - - -## Examples - This example renames the `Test` directory to `SecondTest`. - - :::code language="vb" source="~/snippets/visualbasic/Microsoft.VisualBasic.Devices/ServerComputer/FileSystem/Class1.vb" id="Snippet13"::: - ]]> @@ -4118,15 +3835,6 @@ |--------|---------| |Rename a file|[How to: Rename a File](/dotnet/visual-basic/developing-apps/programming/drives-directories-files/how-to-rename-a-file)| - - -## Examples - This example renames the file `Test.txt` to `SecondTest.txt`. - - :::code language="vb" source="~/snippets/visualbasic/Microsoft.VisualBasic.Devices/ServerComputer/FileSystem/Class1.vb" id="Snippet1"::: - - Change "`C:\Test.txt`" to the path and file name of the file that you want to rename. - ]]> @@ -4180,16 +3888,7 @@ Gets an object that provides properties for accessing commonly referenced directories. This property returns the object for the computer. - - - + To be added. Objects (Visual Basic) @@ -4250,13 +3949,6 @@ |--------|---------| |Write to a binary file|[How to: Write to Binary Files](/dotnet/visual-basic/developing-apps/programming/drives-directories-files/how-to-write-to-binary-files)| - - -## Examples - This example appends the data array `CustomerData` to the file `CollectedData`. - - :::code language="vb" source="~/snippets/visualbasic/Microsoft.VisualBasic.Devices/ServerComputer/FileSystem/Class1.vb" id="Snippet50"::: - ]]> The path is not valid for one of the following reasons: it is a zero-length string; it contains only white space; it contains invalid characters; or it is a device path (starts with \\\\.\\); it ends with a trailing slash. diff --git a/xml/Microsoft.VisualBasic.MyServices/SpecialDirectoriesProxy.xml b/xml/Microsoft.VisualBasic.MyServices/SpecialDirectoriesProxy.xml index 7f32667a6ea..28809289377 100644 --- a/xml/Microsoft.VisualBasic.MyServices/SpecialDirectoriesProxy.xml +++ b/xml/Microsoft.VisualBasic.MyServices/SpecialDirectoriesProxy.xml @@ -37,38 +37,27 @@ Provides properties for accessing commonly referenced directories. - exception is thrown. - - No backslash (\\) appears at the end of the path. - - The following table lists examples of tasks involving the `My.Computer.FileSystem.SpecialDirectories` object. - -|To|See| -|--------|---------| -|Read from the MyDocuments directory|[How to: Retrieve the Contents of the My Documents Directory](/dotnet/visual-basic/developing-apps/programming/drives-directories-files/how-to-retrieve-the-contents-of-the-my-documents-directory)| - -## Availability by Project Type - -|Project type|Available| -|------------------|---------------| -|Windows Application|**Yes**| -|Class Library|**Yes**| -|Console Application|**Yes**| -|Windows Control Library|**Yes**| -|Web Control Library|**Yes**| -|Windows Service|**Yes**| -|Web Site|**Yes**| - - - -## Examples - This example returns the `filePath` for the user's Desktop directory and displays it. - - :::code language="vb" source="~/snippets/visualbasic/Microsoft.VisualBasic.Devices/ServerComputer/FileSystem/Class1.vb" id="Snippet80"::: - + exception is thrown. + + No backslash (\\) appears at the end of the path. + +To read from the MyDocuments directory, see [How to: Retrieve the Contents of the My Documents Directory](/dotnet/visual-basic/developing-apps/programming/drives-directories-files/how-to-retrieve-the-contents-of-the-my-documents-directory). + +## Availability by Project Type + +| Project type | Available | +|-------------------------|-----------| +| Windows Application | **Yes** | +| Class Library | **Yes** | +| Console Application | **Yes** | +| Windows Control Library | **Yes** | +| Web Control Library | **Yes** | +| Windows Service | **Yes** | +| Web Site | **Yes** | + ]]> @@ -110,18 +99,11 @@ Gets a path name pointing to the Application Data directory for the all users. The path to the Application Data directory for the all users. - . - - :::code language="vb" source="~/snippets/visualbasic/Microsoft.VisualBasic.Devices/ServerComputer/FileSystem/Class1.vb" id="Snippet79"::: - + The path is empty, usually because the operating system does not support the directory. @@ -164,18 +146,11 @@ Gets a path name pointing to the Application Data directory for the current user. The path to the Application Data directory for the current user. - . - - :::code language="vb" source="~/snippets/visualbasic/Microsoft.VisualBasic.Devices/ServerComputer/FileSystem/Class1.vb" id="Snippet48"::: - + The path is empty, usually because the operating system does not support the directory. @@ -218,18 +193,11 @@ Gets a path name pointing to the Desktop directory. The path to the Desktop directory. - . - - :::code language="vb" source="~/snippets/visualbasic/Microsoft.VisualBasic.Devices/ServerComputer/FileSystem/Class1.vb" id="Snippet60"::: - + The path is empty, usually because the operating system does not support the directory. @@ -272,18 +240,11 @@ Gets a path name pointing to the My Documents directory. The path to the My Documents directory. - . - - :::code language="vb" source="~/snippets/visualbasic/Microsoft.VisualBasic.Devices/ServerComputer/FileSystem/Class1.vb" id="Snippet53"::: - + The path is empty, usually because the operating system does not support the directory. @@ -326,18 +287,11 @@ Gets a path name pointing to the My Music directory. The path to the My Music directory. - . - - :::code language="vb" source="~/snippets/visualbasic/Microsoft.VisualBasic.Devices/ServerComputer/FileSystem/Class1.vb" id="Snippet26"::: - + The path is empty, usually because the operating system does not support the directory. @@ -380,18 +334,11 @@ Gets a path name pointing to the My Pictures directory. The path to the My Pictures directory. - . - - :::code language="vb" source="~/snippets/visualbasic/Microsoft.VisualBasic.Devices/ServerComputer/FileSystem/Class1.vb" id="Snippet77"::: - + The path is empty, usually because the operating system does not support the directory. @@ -434,18 +381,11 @@ Gets a path pointing to the **Program Files** directory. The path to the **Program Files** directory. - . - - :::code language="vb" source="~/snippets/visualbasic/Microsoft.VisualBasic.Devices/ServerComputer/FileSystem/Class1.vb" id="Snippet90"::: - + The path is empty, usually because the operating system does not support the directory. @@ -488,18 +428,11 @@ Gets a path name pointing to the Programs directory. The path to the Programs directory. - . - - :::code language="vb" source="~/snippets/visualbasic/Microsoft.VisualBasic.Devices/ServerComputer/FileSystem/Class1.vb" id="Snippet61"::: - + The path is empty, usually because the operating system does not support the directory. @@ -542,18 +475,11 @@ Gets a path name pointing to the Temp directory. The path to the Temp directory. - . - - :::code language="vb" source="~/snippets/visualbasic/Microsoft.VisualBasic.Devices/ServerComputer/FileSystem/Class1.vb" id="Snippet31"::: - + The path is empty, usually because the operating system does not support the directory. From 36ff7fff97b4c26dcb5e4c0ebe13b667e63b0859 Mon Sep 17 00:00:00 2001 From: Genevieve Warren <24882762+gewarren@users.noreply.github.com> Date: Fri, 31 Jul 2026 15:25:50 -0700 Subject: [PATCH 3/3] respond to CCR --- .../FrameworkName/op_Equality/Operators1.cs | 2 +- snippets/fsharp/System/Type/Assembly/type_assembly.fs | 2 +- .../FrameworkName/op_Equality/Operators1.vb | 2 +- snippets/visualbasic/System/Type/Assembly/type_assembly.vb | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/snippets/csharp/System.Runtime.Versioning/FrameworkName/op_Equality/Operators1.cs b/snippets/csharp/System.Runtime.Versioning/FrameworkName/op_Equality/Operators1.cs index af2bfedfff5..eb31bc6fb26 100644 --- a/snippets/csharp/System.Runtime.Versioning/FrameworkName/op_Equality/Operators1.cs +++ b/snippets/csharp/System.Runtime.Versioning/FrameworkName/op_Equality/Operators1.cs @@ -40,7 +40,7 @@ private static void TestForInequality() FrameworkName actualVersion = new($".NET, Version={Environment.Version}"); Console.WriteLine($"Given Version: {version}"); - Console.WriteLine($"Actual Version {actualVersion}"); + Console.WriteLine($"Actual Version: {actualVersion}"); if (version != actualVersion) Console.WriteLine("The versions are different."); else diff --git a/snippets/fsharp/System/Type/Assembly/type_assembly.fs b/snippets/fsharp/System/Type/Assembly/type_assembly.fs index 9c330bbcdf7..ba98e5ee73e 100644 --- a/snippets/fsharp/System/Type/Assembly/type_assembly.fs +++ b/snippets/fsharp/System/Type/Assembly/type_assembly.fs @@ -14,6 +14,6 @@ printfn $"Assembly qualified name:\n {objType.AssemblyQualifiedName}." // Assembly full name: // System.Private.CoreLib, Version = 10.0.0.0, Culture = neutral, PublicKeyToken = 7cec85d7bea7798e. // Assembly qualified name: -// System.Array, System.Private.CoreLib, Version = 10.0.0.0, Culture = neutral, PublicKeyToken = 7cec85d7bea779 +// System.Array, System.Private.CoreLib, Version = 10.0.0.0, Culture = neutral, PublicKeyToken = 7cec85d7bea7798e. // diff --git a/snippets/visualbasic/System.Runtime.Versioning/FrameworkName/op_Equality/Operators1.vb b/snippets/visualbasic/System.Runtime.Versioning/FrameworkName/op_Equality/Operators1.vb index c84ad8acd8f..6fcb9c67e6e 100644 --- a/snippets/visualbasic/System.Runtime.Versioning/FrameworkName/op_Equality/Operators1.vb +++ b/snippets/visualbasic/System.Runtime.Versioning/FrameworkName/op_Equality/Operators1.vb @@ -39,7 +39,7 @@ Module Example Dim actualVersion As New FrameworkName($".NET, Version={Environment.Version}") Console.WriteLine($"Given Version: {version}") - Console.WriteLine($"Actual Version {actualVersion}") + Console.WriteLine($"Actual Version: {actualVersion}") If version <> actualVersion Then Console.WriteLine("The versions are different.") Else diff --git a/snippets/visualbasic/System/Type/Assembly/type_assembly.vb b/snippets/visualbasic/System/Type/Assembly/type_assembly.vb index 8e7ec08b4e9..312b82ff816 100644 --- a/snippets/visualbasic/System/Type/Assembly/type_assembly.vb +++ b/snippets/visualbasic/System/Type/Assembly/type_assembly.vb @@ -16,6 +16,6 @@ End Class ' Assembly full name: ' System.Private.CoreLib, Version = 10.0.0.0, Culture = neutral, PublicKeyToken = 7cec85d7bea7798e. ' Assembly qualified name: - System.Array, System.Private.CoreLib, Version = 10.0.0.0, Culture = neutral, PublicKeyToken = 7cec85d7bea7798e. +' System.Array, System.Private.CoreLib, Version = 10.0.0.0, Culture = neutral, PublicKeyToken = 7cec85d7bea7798e. '