Why would myString.Contains(" ")
or myString.IndexOf(' ')
throw a FormatException "Invalid name format"? This exception is only thrown when there is a space in myString
.
Looking at the MSDN pages for the string.Contains
and string.IndexOf
methods clearly shows that neither of these methods ever throws a FormatException
.
I can only conclude that it must be another part of the code (possibly a call to string.Format
?) throwing this exception. Perhaps posting the relevant section of code would help?
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.