Get int value from enum in C#

Just cast the enum, e.g. The above will work for the vast majority of enums you see in the wild, as the default underlying type for an enum is int. However, as cecilphillip points out, enums can have different underlying types. If an enum is declared as a uint, long, or ulong, it should be … Read more

What does the Ellipsis object do?

This came up in another question recently. I’ll elaborate on my answer from there: Ellipsis is an object that can appear in slice notation. For example: Its interpretation is purely up to whatever implements the __getitem__ function and sees Ellipsis objects there, but its main (and intended) use is in the numpy third-party library, which … Read more

MySQL AS keyword

I’m not professional in query writing, but wrote many from the time I began MySQL. Recently I noticed there is no need to type AS keyword in name aliasing. equals to However I know that this ability is out from years ago. I’ve 2 questions around this subject: Is AS keyword redundant? Sometimes ago when … Read more

Big-oh vs big-theta

Big-O is an upper bound. Big-Theta is a tight bound, i.e. upper and lower bound. When people only worry about what’s the worst that can happen, big-O is sufficient; i.e. it says that “it can’t get much worse than this”. The tighter the bound the better, of course, but a tight bound isn’t always easy … Read more

Specified cast is not valid?

From your comment: this line DateTime Date = reader.GetDateTime(0); was throwing the exception The first column is not a valid DateTime. Most likely, you have multiple columns in your table, and you’re retrieving them all by running this query: Replace it with a query that retrieves only the two columns you’re interested in: Then try … Read more

Escape double quotes in a string

No. Either use verbatim string literals as you have, or escape the ” using backslash. The string has not changed in either case – there is a single escaped ” in it. This is just a way to tell C# that the character is part of the string and not a string terminator.