Browsing 7239 questions and answers with Jon Skeet
I have a date stored in a date variable(java.util.Date), (say 2015-4-4 15:30:26-0700) in yyyy-mm-dd hh:mm:ss timezone format. No, you have a Date variable. That doesn't have any particular format. Ignore what toString() tells you -... more 7/28/2015 12:47:04 PM
Now I'd say that I can't do the same for ClassB since the accessibility of the constructor is increased from protected to public. That's irrelevant, given that it's an abstract class. The constructor can't be called directly - it's... more 7/28/2015 12:32:25 PM
The if statement Ive put in doesn't work it throws several errors. Yes, it would - you've put it in an object initializer. Object initializers aren't arbitrary blocks of code - they're a list of property = value assignments,... more 7/28/2015 12:23:50 PM
It is unboxing - but it's doing it implicitly. There's an implicit conversion from any dynamic expression to any type. The exact conversion performed will depend on the execution-time type of the value. From section 6.1.8 of the C# 5... more 7/28/2015 12:16:27 PM
That's absolutely fine. In fact, it's a good way of making a parameter optional without having to bake in the value as a constant. You can use the null-coalescing operator to make it slightly more readable though: fooObj = fooObj ??... more 7/28/2015 12:05:51 PM
In readFromFile you're calling openFileInput, instead of the FileInputStream constructor. So do the same thing when you want to create an InputSource: inputSource = new InputSource(openFileInput(filename)); more 7/28/2015 9:50:40 AM
You're calling the POIFSFileSystem(InputStream) constructor, which is documented as: Create a POIFSFileSystem from an InputStream. Normally the stream is read until EOF. The stream is always closed. (Emphasis mine.) That means... more 7/28/2015 5:59:47 AM
Look at this loop: for (int i = 0; i <= checkedListBox1.CheckedItems.Count - 1; i++) { NpgsqlCommand cmd = new NpgsqlCommand("Insert into famhistory(famcon) Values (@famcon)", conn); cmd.Parameters.AddWithValue("@famcon",... more 7/28/2015 5:48:18 AM
Why this code prints "I am an int" and not "I am a long" ? Because the compiler goes through the rules of overload resolution, which are in the C# 5 spec, starting at section 7.5.3. Both of those are applicable function members (i.e.... more 7/27/2015 8:12:37 PM
To simplify it: int? x = null; string result = x.ToString(); // No exception Here null isn't a null reference. It's just a null value of the type int?, i.e. a value of type Nullable<int> where HasValue is false. You're just... more 7/27/2015 2:30:07 PM