How do I check if a string is a number (float)?

Which, not only is ugly and slow I’d dispute both. A regex or other string parsing method would be uglier and slower. I’m not sure that anything much could be faster than the above. It calls the function and returns. Try/Catch doesn’t introduce much overhead because the most common exception is caught without an extensive … Read more

How to convert integer to string in C?

Use sprintf(): All numbers that are representable by int will fit in a 12-char-array without overflow, unless your compiler is somehow using more than 32-bits for int. When using numbers with greater bitsize, e.g. long with most 64-bit compilers, you need to increase the array sizeā€”at least 21 characters for 64-bit types.

Cannot implicitly convert type ‘customtype’ to ‘othercustomtype’

Because a Person is not nessecarily a User, the compiler is not able to implicitly convert a Person to a User. In your particular case, since you know you have a list of Users, you can explicitly tell it, “I know this Person is actually a User” with the following: The cast ((User)) will throw an exception at runtime if the instance is not actually a User, but … Read more