Browsing 7239 questions and answers with Jon Skeet
Contrary to the comments, TimeSpan does not help you here, because a year is not a fixed length of time. That in turn leads to your expressed aim being very strange indeed. You really shouldn't be representing a date as a fractional number... more 10/22/2014 9:25:15 AM
No, there's nothing within the framework that does this as far as I'm aware. Your second option seems sensible to me. You'll need to make it read-only, throwing appropriate exceptions for the mutating operations of IList<T>. One... more 10/22/2014 8:46:28 AM
You're using the Portable Class Library subset of .NET; that doesn't include List<T>.ForEach. Personally I'm not keen on this approach anyway - it would be much more readable IMO to use LINQ to select the right company. After all,... more 10/22/2014 8:41:00 AM
I ask you this becouse i have large date base on my servers and if this swich happens instantly one hour on entryes in the data base will pe owerwritten That suggests you're writing the local time into the database. Regardless of how... more 10/22/2014 8:33:26 AM
Assuming InvoiceMaster derives from or implements InvoiceHD, and that you're using C# 4 and .NET 4 or higher, you can just use generic variance: return MstDtl.ToList<InvoiceHD>(); This uses the fact that an... more 10/22/2014 6:18:32 AM
It's not entirely clear what merge operations you need to perform - but if you just need to copy the root node's child elements, that's really simple with LINQ to XML: XDocument doc1 = XDocument.Load("test1.xml"); XDocument doc2 =... more 10/22/2014 6:08:52 AM
To sum up: does "catch Exception e" catch all kinds of exceptions or should each one be named individually It catches everything of type Exception or a subclass. It will not catch other Throwables, e.g. Error. But given that all the... more 10/21/2014 4:55:14 PM
if one thread acquire the inner lock, other threads that acquired the outer lock, will remains inside the foo function? Yes. They will block, waiting to acquire the monitor for string. When on thread ,for some reasons, remains... more 10/21/2014 4:45:08 PM
Could someone explain me what's wrong? The compiler is telling you exactly what's wrong - the call is ambiguous. The fact that you're trying to use the result of the call to assign into a decimal array is irrelevant to the compiler -... more 10/21/2014 10:51:44 AM
I would strongly recommend that you get rid of all the string manipulation. Your query doesn't conceptually have anything to do with strings, so why are you introducing them into the code? You can write your query as: int currentMonth =... more 10/21/2014 10:33:58 AM