Browsing 7239 questions and answers with Jon Skeet
I suspect your implementation (which you haven't shown) uses BigInteger or something similar. Java just uses int - so when it overflows the range of positive 31-bit integers, it goes into large negative integers, and then as you add more... more 3/10/2015 10:19:22 AM
I suspect it's due to definite assignment. If you assign a value to holdLastObject before the loop, it's definitely assigned for the whole method (from the point of declaration onwards) - so even though you don't access it after the loop,... more 3/10/2015 6:58:31 AM
Is there a way to guarantee at build time that a class matches the interface parameter names? I would prefer not to do this manually. Not within the C# language. However: You could write a unit test to check, reasonably easily. Not... more 3/9/2015 10:33:38 PM
Firstly, you should separate DateTime formatting from time zones. They're completely separate problems. For most scenarios (but not all), you should save values in your database in UTC, and convert them to the appropriate time zone when... more 3/9/2015 7:54:13 PM
Well, there are a few options: Create an array yourself: varadric(new Object[] { array }) Declare a local variable of type Object and get the compiler to wrap that in an array: Object tmp = array; varadric(tmp); A variation on the... more 3/9/2015 7:24:08 PM
You're closing the scanner near the end of the method. That closes the stream it's working on - System.in in this case. That means next time you call the method, the stream is still closed, so there are no lines. You should set up one... more 3/9/2015 7:13:23 PM
Firstly, this has nothing to do with System.out.println. You'll see exactly the same effect if you use: String x = 7 + 5 + ""; String y = " " + 5 + 7; It's got everything to do with associativity. The + operator is left-associative, so... more 3/9/2015 5:57:46 PM
Will m_rooms be copied when client code will access Rooms property Yes. But the value of m_rooms is just a reference - it's not a List<Room> object in itself. You might want to read my article about reference types and value... more 3/9/2015 5:39:21 PM
Sure, just save it to a MemoryStream instead: using (MemoryStream ms = new MemoryStream()) { // Odd to have a constructor but not use the newly-created object. // Smacks of the constructor doing too much. var ignored = new... more 3/9/2015 4:15:57 PM
It sounds like you want to expose a ReadOnlyDictionary. You could create a new one each time the property is accessed, or you could have two fields - one for the writable dictionary (which you never expose) and one for the read-only... more 3/9/2015 1:55:43 PM