diff --git a/machine-learning/tutorials/TransferLearningTF/Program.cs b/machine-learning/tutorials/TransferLearningTF/Program.cs index e610c23772b..99afb795776 100644 --- a/machine-learning/tutorials/TransferLearningTF/Program.cs +++ b/machine-learning/tutorials/TransferLearningTF/Program.cs @@ -136,10 +136,10 @@ public static void ClassifyImages(MLContext mlContext, string dataLocation, stri // Read the image_list.tsv file and add the filepath to the image file name // before loading into ImageData - // + // var imageData = ReadFromTsv(dataLocation, imagesFolder); var imageDataView = mlContext.Data.LoadFromEnumerable(imageData); - // + // // var predictions = model.Transform(imageDataView); diff --git a/snippets/csharp/VS_Snippets_CLR/conceptual.regularexpressions.objectmodel/cs/capture1.cs b/snippets/csharp/VS_Snippets_CLR/conceptual.regularexpressions.objectmodel/cs/capture1.cs index 03420ad4990..6494ab470dc 100644 --- a/snippets/csharp/VS_Snippets_CLR/conceptual.regularexpressions.objectmodel/cs/capture1.cs +++ b/snippets/csharp/VS_Snippets_CLR/conceptual.regularexpressions.objectmodel/cs/capture1.cs @@ -24,4 +24,5 @@ public static void Main() // Chicago 62 // New York 67 // San Francisco 59 +// Seattle 58 // diff --git a/snippets/standard/base-types/string-practices/cs/formattable.cs b/snippets/standard/base-types/string-practices/cs/formattable.cs new file mode 100644 index 00000000000..231fd6eea0e --- /dev/null +++ b/snippets/standard/base-types/string-practices/cs/formattable.cs @@ -0,0 +1,18 @@ +using System; +using System.Globalization; + +class Program +{ + static void Main() + { + Decimal value = 126.03m; + FormattableString amount = $"The amount is {value:C}"; + Console.WriteLine(amount.ToString()); + Console.WriteLine(amount.ToString(new CultureInfo("fr-FR"))); + Console.WriteLine(FormattableString.Invariant(amount)); + } +} +// The example displays the following output: +// The amount is $126.03 +// The amount is 126,03 € +// The amount is ¤126.03 diff --git a/snippets/standard/base-types/string-practices/cs/tostring.cs b/snippets/standard/base-types/string-practices/cs/tostring.cs new file mode 100644 index 00000000000..e4a9dd05bda --- /dev/null +++ b/snippets/standard/base-types/string-practices/cs/tostring.cs @@ -0,0 +1,18 @@ +using System; +using System.Globalization; + +class Program +{ + static void Main(string[] args) + { + // + string concat1 = "The amount is " + 126.03 + "."; + Console.WriteLine(concat1); + // + + // + string concat2 = "The amount is " + 126.03.ToString(CultureInfo.InvariantCulture) + "."; + Console.WriteLine(concat2); + // + } +} diff --git a/snippets/standard/base-types/string-practices/vb/formattable.vb b/snippets/standard/base-types/string-practices/vb/formattable.vb new file mode 100644 index 00000000000..7e63f647dfa --- /dev/null +++ b/snippets/standard/base-types/string-practices/vb/formattable.vb @@ -0,0 +1,15 @@ +Imports System.Globalization + +Module Program + Sub Main() + Dim value As Decimal = 126.03 + Dim amount As FormattableString = $"The amount is {value:C}" + Console.WriteLine(amount.ToString()) + Console.WriteLine(amount.ToString(new CultureInfo("fr-FR"))) + Console.WriteLine(FormattableString.Invariant(amount)) + End Sub +End Module +' The example displays the following output: +' The amount is $126.03 +' The amount is 126,03 € +' The amount is ¤126.03 diff --git a/snippets/standard/interop/pinvoke/enumwindows.cs b/snippets/standard/interop/pinvoke/enumwindows.cs new file mode 100644 index 00000000000..4e0af395078 --- /dev/null +++ b/snippets/standard/interop/pinvoke/enumwindows.cs @@ -0,0 +1,29 @@ +using System; +using System.Runtime.InteropServices; + +namespace ConsoleApplication1 +{ + public static class Program + { + // Define a delegate that corresponds to the unmanaged function. + private delegate bool EnumWC(IntPtr hwnd, IntPtr lParam); + + // Import user32.dll (containing the function we need) and define + // the method corresponding to the native function. + [DllImport("user32.dll")] + private static extern int EnumWindows(EnumWC lpEnumFunc, IntPtr lParam); + + // Define the implementation of the delegate; here, we simply output the window handle. + private static bool OutputWindow(IntPtr hwnd, IntPtr lParam) + { + Console.WriteLine(hwnd.ToInt64()); + return true; + } + + public static void Main(string[] args) + { + // Invoke the method; note the delegate as a first parameter. + EnumWindows(OutputWindow, IntPtr.Zero); + } + } +} diff --git a/snippets/standard/interop/pinvoke/ftw-linux.cs b/snippets/standard/interop/pinvoke/ftw-linux.cs new file mode 100644 index 00000000000..4f7be2e4ce8 --- /dev/null +++ b/snippets/standard/interop/pinvoke/ftw-linux.cs @@ -0,0 +1,51 @@ +using System; +using System.Runtime.InteropServices; + +namespace PInvokeSamples +{ + public static class Program + { + // Define a delegate that has the same signature as the native function. + private delegate int DirClbk(string fName, StatClass stat, int typeFlag); + + // Import the libc and define the method to represent the native function. + [DllImport("libc.so.6")] + private static extern int ftw(string dirpath, DirClbk cl, int descriptors); + + // Implement the above DirClbk delegate; + // this one just prints out the filename that is passed to it. + private static int DisplayEntry(string fName, StatClass stat, int typeFlag) + { + Console.WriteLine(fName); + return 0; + } + + public static void Main(string[] args) + { + // Call the native function. + // Note the second parameter which represents the delegate (callback). + ftw(".", DisplayEntry, 10); + } + } + + // The native callback takes a pointer to a struct. The below class + // represents that struct in managed code. You can find more information + // about this in the section on marshalling below. + [StructLayout(LayoutKind.Sequential)] + public class StatClass + { + public uint DeviceID; + public uint InodeNumber; + public uint Mode; + public uint HardLinks; + public uint UserID; + public uint GroupID; + public uint SpecialDeviceID; + public ulong Size; + public ulong BlockSize; + public uint Blocks; + public long TimeLastAccess; + public long TimeLastModification; + public long TimeLastStatusChange; + } +} diff --git a/snippets/standard/interop/pinvoke/ftw-macos.cs b/snippets/standard/interop/pinvoke/ftw-macos.cs new file mode 100644 index 00000000000..69f59a8fac8 --- /dev/null +++ b/snippets/standard/interop/pinvoke/ftw-macos.cs @@ -0,0 +1,50 @@ +using System; +using System.Runtime.InteropServices; + +namespace PInvokeSamples +{ + public static class Program + { + // Define a delegate that has the same signature as the native function. + private delegate int DirClbk(string fName, StatClass stat, int typeFlag); + + // Import the libc and define the method to represent the native function. + [DllImport("libSystem.dylib")] + private static extern int ftw(string dirpath, DirClbk cl, int descriptors); + + // Implement the above DirClbk delegate; + // this one just prints out the filename that is passed to it. + private static int DisplayEntry(string fName, StatClass stat, int typeFlag) + { + Console.WriteLine(fName); + return 0; + } + + public static void Main(string[] args) + { + // Call the native function. + // Note the second parameter which represents the delegate (callback). + ftw(".", DisplayEntry, 10); + } + } + + // The native callback takes a pointer to a struct. The below class + // represents that struct in managed code. + [StructLayout(LayoutKind.Sequential)] + public class StatClass + { + public uint DeviceID; + public uint InodeNumber; + public uint Mode; + public uint HardLinks; + public uint UserID; + public uint GroupID; + public uint SpecialDeviceID; + public ulong Size; + public ulong BlockSize; + public uint Blocks; + public long TimeLastAccess; + public long TimeLastModification; + public long TimeLastStatusChange; + } +} diff --git a/snippets/standard/interop/pinvoke/getpid-linux.cs b/snippets/standard/interop/pinvoke/getpid-linux.cs new file mode 100644 index 00000000000..4a23cbc269b --- /dev/null +++ b/snippets/standard/interop/pinvoke/getpid-linux.cs @@ -0,0 +1,20 @@ +using System; +using System.Runtime.InteropServices; + +namespace PInvokeSamples +{ + public static class Program + { + // Import the libc shared library and define the method + // corresponding to the native function. + [DllImport("libc.so.6")] + private static extern int getpid(); + + public static void Main(string[] args) + { + // Invoke the function and get the process ID. + int pid = getpid(); + Console.WriteLine(pid); + } + } +} diff --git a/snippets/standard/interop/pinvoke/getpid-macos.cs b/snippets/standard/interop/pinvoke/getpid-macos.cs new file mode 100644 index 00000000000..ef77987a3bf --- /dev/null +++ b/snippets/standard/interop/pinvoke/getpid-macos.cs @@ -0,0 +1,20 @@ +using System; +using System.Runtime.InteropServices; + +namespace PInvokeSamples +{ + public static class Program + { + // Import the libSystem shared library and define the method + // corresponding to the native function. + [DllImport("libSystem.dylib")] + private static extern int getpid(); + + public static void Main(string[] args) + { + // Invoke the function and get the process ID. + int pid = getpid(); + Console.WriteLine(pid); + } + } +} diff --git a/snippets/standard/interop/pinvoke/messagebox.cs b/snippets/standard/interop/pinvoke/messagebox.cs new file mode 100644 index 00000000000..7aea3cfc241 --- /dev/null +++ b/snippets/standard/interop/pinvoke/messagebox.cs @@ -0,0 +1,16 @@ +using System; +using System.Runtime.InteropServices; + +public class Program +{ + // Import user32.dll (containing the function we need) and define + // the method corresponding to the native function. + [DllImport("user32.dll", CharSet = CharSet.Unicode, SetLastError = true)] + private static extern int MessageBox(IntPtr hWnd, string lpText, string lpCaption, uint uType); + + public static void Main(string[] args) + { + // Invoke the function as a regular managed method. + MessageBox(IntPtr.Zero, "Command-line message box", "Attention!", 0); + } +} diff --git a/snippets/visualbasic/VS_Snippets_CLR/conceptual.regularexpressions.objectmodel/vb/capture1.vb b/snippets/visualbasic/VS_Snippets_CLR/conceptual.regularexpressions.objectmodel/vb/capture1.vb index 6a6638a49c2..6e9a1580a42 100644 --- a/snippets/visualbasic/VS_Snippets_CLR/conceptual.regularexpressions.objectmodel/vb/capture1.vb +++ b/snippets/visualbasic/VS_Snippets_CLR/conceptual.regularexpressions.objectmodel/vb/capture1.vb @@ -24,4 +24,5 @@ End Module ' Chicago 62 ' New York 67 ' San Francisco 59 +' Seattle 58 ' diff --git a/snippets/visualbasic/VS_Snippets_VBCSharp/VbVbcnMyFileSystem/VB/Class1.vb b/snippets/visualbasic/VS_Snippets_VBCSharp/VbVbcnMyFileSystem/VB/Class1.vb index f35a73433c8..73e217d94b8 100644 --- a/snippets/visualbasic/VS_Snippets_VBCSharp/VbVbcnMyFileSystem/VB/Class1.vb +++ b/snippets/visualbasic/VS_Snippets_VBCSharp/VbVbcnMyFileSystem/VB/Class1.vb @@ -9,6 +9,7 @@ Imports System.IO Imports System.Drawing Imports System.Windows.Forms +Imports Microsoft.VisualBasic.FileIO Class Class00ad6fbd924e4a49af32d505fe69ea32 ' 00ad6fbd-924e-4a49-af32-d505fe69ea32 @@ -1071,4 +1072,32 @@ Class Class7bb0d83e875a4b158935bdc24e71ef98 End Class +Class Classe02587a6e85494d7f9392beae2c7f3903 + '02587a6e-8549-4d7f-9392-beae2c7f3903 + ' My.Computer.FileSystem.CopyDirectory Method + Public Sub Method91() + ' + 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