Aracılığıyla paylaş


Parse vs. TryParse Application Sample

This sample demonstrates the performance benefits of using the TryParse method, exposed by several classes in the System namespace, in comparison to that type's Parse method.

For information about using the samples, see How to: View and Download Samples.

To build the sample using the Command Prompt

  1. Open a Command Prompt window and navigate to one of the language-specific subdirectories under the TryParse directory. (Make sure that the Path environment variable includes the path to the MSBuild.exe executable.)

  2. Type msbuild TryParseDemoCS.sln or msbuild TryParseDemoVB.sln, depending on your choice of programming language, at the command line.

To build the sample using Visual Studio

  1. Open Windows Explorer and navigate to one of the language-specific subdirectories under the TryParse directory.

  2. Double-click the icon for the TryParseDemoCS.sln or TryParseDemoVB.sln file, depending on your choice of programming language, to open the file in Visual Studio 2005.

  3. On the Build menu, click Build Solution.

The application will be built in the default \bin or \bin\Debug directory.

To run the sample

  1. Navigate to the directory that contains the new executable, using the command prompt or Windows Explorer.

  2. Type TryParseDemo.exe at the command line, or double-click the icon for TryParseDemo.exe to run it from Windows Explorer.

See Also

Reference

Boolean.TryParse

Byte.TryParse

DateTime.TryParse

Char.TryParse

Decimal.TryParse

Double.TryParse

Int16.TryParse

Int32.TryParse

Int64.TryParse

SByte.TryParse

Single.TryParse

UInt16.TryParse

UInt32.TryParse

UInt64.TryParse