This article is a mirror article of machine translation, please click here to jump to the original article.

View: 16605|Reply: 1

[ASP.NET] When you help build a website, System.InvalidCastException appears: Specified transfer...

[Copy link]
Posted on 11/17/2017 9:46:49 PM | | | |
Posted on 11/18/2017 9:23:27 AM |
Try it with Convert.ToInt32().

1. int is suitable for conversion between simple data types, and the default integer of C# is int32 (bool type is not supported);

2、int. Parse(string sParameter) is a constructor, and the parameter type only supports string type.

3. Convert.ToInt32() is suitable for converting Object type to int type;

4. Convert.ToInt32() and int. Parse() nuances:

Unlike null, Convert.ToInt32(null) returns 0 without any exceptions, but int. Parse(null) will produce an exception.
Disclaimer:
All software, programming materials or articles published by Code Farmer Network are only for learning and research purposes; The above content shall not be used for commercial or illegal purposes, otherwise, users shall bear all consequences. The information on this site comes from the Internet, and copyright disputes have nothing to do with this site. You must completely delete the above content from your computer within 24 hours of downloading. If you like the program, please support genuine software, purchase registration, and get better genuine services. If there is any infringement, please contact us by email.

Mail To:help@itsvse.com