Partager via


Troubleshooting Exceptions: System.FormatException 

A FormatException exception is thrown when the format of an argument does not meet the parameter specifications of the invoked members. For example, if a method specifies a string parameter consisting of two digits with an embedded period, passing a string argument containing only two digits to that method would cause a FormatException exception to be thrown.

Associated Tips

  • Make sure your method arguments are in the right format.
    The format of your method arguments must meet the parameter specifications of the invoked members.
  • When converting a string to DateTime, parse the string to take the date before putting each variable in the DateTime object.
    For example, DateTime.Minute = 30. For more information, see DateTime.

See Also

Tasks

How to: Find Out More About an Exception with the Exception Assistant

Reference

FormatException