Share via


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 the following topics:

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. For information about required settings and the SDK Command Prompt, see How to: Set Sample Settings.

  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.

Remarks

See Also

Reference

System.Boolean.TryParse(System.String,System.Boolean)
System.Byte.TryParse
System.DateTime.TryParse
System.Char.TryParse(System.String,System.Char)
System.Decimal.TryParse
System.Double.TryParse
System.Int16.TryParse
System.Int32.TryParse
System.Int64.TryParse
System.SByte.TryParse
System.Single.TryParse
System.UInt16.TryParse
System.UInt32.TryParse
System.UInt64.TryParse