Why is a SQL float different from a C# float
A SQL float is a double according to the documentation for SQLDbType.
A SQL float is a double according to the documentation for SQLDbType.
Here’s a blog post describing the creation of an IsInteger UDF. Basically, it recommends adding ‘.e0’ to the value and using IsNumeric. In this way, anything that already had a decimal point now has two decimal points, causing IsNumeric to be false, and anything already expressed in scientific notation is invalidated by the e0.
You have to use Nullable.GetUnderlyingType to get underlying type of Nullable. This is the method I use to overcome limitation of ChangeType for Nullable public static T ChangeType<T>(object value) { var t = typeof(T); if (t.IsGenericType && t.GetGenericTypeDefinition().Equals(typeof(Nullable<>))) { if (value == null) { return default(T); } t = Nullable.GetUnderlyingType(t); } return (T)Convert.ChangeType(value, t); } … Read more
You’ve tagged this with three languages, and the answers are really quite different between the three. Discussion of C++ more or less implies discussion of C casts as well, and that gives (more or less) a fourth answer. Since it’s the one you didn’t mention explicitly, I’ll start with C. C casts have a number … Read more
This will also happen if you’ve forgotten to specify public inheritance on the derived class, i.e. if like me you write this: class Derived : Base { }; Instead of: class Derived : public Base { };
Those are all slightly different, and generally have an acceptable usage. var.ToString() is going to give you the string representation of an object, regardless of what type it is. Use this if var is not a string already. CStr(var) is the VB string cast operator. I’m not a VB guy, so I would suggest avoiding … Read more
There is no implicit (automatic) cast from text or varchar to integer (i.e. you cannot pass a varchar to a function expecting integer or assign a varchar field to an integer one), so you must specify an explicit cast using ALTER TABLE … ALTER COLUMN … TYPE … USING: ALTER TABLE the_table ALTER COLUMN col_name … Read more
You cannot cast it like that. Create a new one: List<A> listA = new ArrayList<A>(listB); The constructor takes Collection<? extends A>. It will point to the same references anyway.
Unfortunately, there’s no easy way to do what you want. Type tests can only be used with specific types, and even if the type test passed, the conversion operator :?> also only works to cast expressions to specific types so the right hand side of your match wouldn’t do what you want anyway. You can … Read more
A char[ROWS][COLS+1] cannot be cast into a char**. The input argument of print_map should be void print_map(char map[][COLS+1]) or void print_map(char (*map)[COLS+1]) The difference being that a char** means to point to something that can be dereferenced like this: (char**)map | v +——–+——–+——+——–+– … | 0x1200 | 0x1238 | NULL | 0x1200 | +—-|—+—-|—+–|—+—-|—+– … … Read more