This sample demonstrates how to use unmanaged code (code using pointers) in C#.
Security Note |
---|
This sample code is provided to illustrate a concept and should not be used in applications or Web sites, as it may not illustrate the safest coding practices. Microsoft assumes no liability for incidental or consequential damages should the sample code be used for purposes other than as intended. |
To build and run the Unsafe Code samples within Visual Studio
In Solution Explorer, right-click the FastCopy project, and click Set as StartUp Project.
On the Debug menu, click Start Without Debugging.
In Solution Explorer, right-click the ReadFile project, and click Set as StartUp Project.
In Solution Explorer, right-click the ReadFile project, and click Properties.
Open the Configuration Properties folder, and click Debug.
In the Command Line Arguments property, enter
..\..\ReadFile.cs
.Click OK.
On the Debug menu, click Start Without Debugging.
In Solution Explorer, right-click the PrintVersion project, and click Set as StartUp Project.
On the Debug menu, click Start Without Debugging.
To build and run the Unsafe Code samples from the Command Line
Use the Change Directory command to change to the Unsafe directory.
Type the following:
cd FastCopy csc FastCopy.cs /unsafe FastCopy
Type the following:
cd ..\ReadFile csc ReadFile.cs /unsafe ReadFile ReadFile.cs
Type the following:
cd ..\PrintVersion csc PrintVersion.cs /unsafe PrintVersion