Browsing 7239 questions and answers with Jon Skeet
You can't, and shouldn't - because it might not be an error. Consider an extra class: class BarBase : IBase, IBar { } Now: IBase item = new BarBase(); IBar bar = item as IBar; That will leave bar as a non-null reference - so why... more 12/16/2015 9:34:29 AM
Here, <CR> means "carriage-return", i.e. "\r". However, if you've got an OutputStream and you want to write text to it, I would suggest wrapping it in an OutputStreamWriter, specifying the appropriate encoding. You can then use... more 12/16/2015 7:25:50 AM
You're not executing the command at all - you're creating a SqlCommand, and then doing nothing with it. You need to call ExecuteNonQuery(). However, you should also stop building the SQL like that. You should start using parameterized SQL... more 12/16/2015 7:20:09 AM
It sounds like you basically need to take the list of elements and group them into groups of 3 elements, putting each group in a Book element: // The name/author/price elements you're already getting var elements = ...; var groups =... more 12/15/2015 10:47:13 PM
This has nothing to do with Enum as such - but extension methods "look" like they're instance methods. You can't "pretend" to add static methods, as it looks like you're currently trying to do. You would be able to... more 12/15/2015 7:17:28 PM
It sounds like your initial date/time is actually in Central time - so once you've performed the initial conversion, you can just say "Hey, I want the same instant in time, but in a different time zone" - which isn't the same as "I want a... more 12/15/2015 6:01:30 PM
Given that you're recording events as they occur (rather than planning for future events), you probably don't need to worry about changes to time zone rules which occur in the future. As such, it would be reasonable to store a timestamp... more 12/15/2015 5:38:30 PM
Yes, there's definitely a better way. You should use the way that queries can be built up in LINQ: public IEnumerable<ProductPeriod> GetFilteredProductPeriods (DateTime? from, DateTime? to, bool? includeActive, bool?... more 12/15/2015 12:14:07 PM
RFC 7515 defines base64url encoding like this: Base64 encoding using the URL- and filename-safe character set defined in Section 5 of RFC 4648, with all trailing '=' characters omitted (as permitted by Section 3.2) and without the ... more 12/15/2015 9:12:52 AM
I think that casting means make one object type turn into another one, so e is Foo type now and just check method one in Foo type. No. Casting doesn't change the type of the object at all. It only gives you an expression of the target... more 12/15/2015 7:25:15 AM