Browsing 7239 questions and answers with Jon Skeet

Unable to resolve assembly reference issue without frameworkAssemblies

I'm trying to validate that Protocol Buffers is going to work with the new portable runtimes from the ASP.NET team and ideally most other modern environments. The 3.0.0-alpha4...
Jon Skeet
people
quotationmark

I've accepted David Fowler's answer as the reason why all of this happened. Now in terms of what I should do about it, it looks like I just need to add a frameworkAssemblies element in the nuspec file for Google.Protobuf: <package> ... more 12/9/2015 10:21:40 AM

people

java left integer pad with zero

How can I get an Integer to be two digits. If it's under 10 it would show 01,02, etc. I want to keep the Integer as an Integer. String.format gives a string. How can I do this...
Jon Skeet
people
quotationmark

If you want to keep the value as an int or Integer, there's nothing to be done here. A number doesn't have a format - it just has a value. For example, an int isn't "in decimal" or "in hex" or "in binary" - if you write int x = 16; int y... more 12/9/2015 7:11:44 AM

people

Why does the exception is thrown if we declare both read and write resources?

I'm experimenting with Serialization and wrote the following class: public static void main(String[] args) throws ClassNotFoundException{ File file = new...
Jon Skeet
people
quotationmark

Well without the write calls, you're currently creating an empty file to start with, because that's what the FileOutputStream constructor you're calling does. If the file already exists, it is truncated to be 0 bytes long. So when you then... more 12/9/2015 7:06:21 AM

people

C# Task.WhenAll not triggering next task

I'm new to multi-tasking, however I'm trying to learn how it all works. I have the following code, which I thought would create a task and run the performInitialLoad method, and...
Jon Skeet
people
quotationmark

Task.WhenAll returns immediately - but it returns a task which will complete when the tasks have completed. You're ignoring that return value at the moment. You're also not starting the task which calls WhenAll, which is why that task is... more 12/8/2015 8:48:59 PM

people

User defined implicit conversion of overloaded operator's arguments

The following operator overload is defined inside my Term class: public static Term operator *(int c, Term t) {...} This class also defines an implicit conversion from a...
Jon Skeet
people
quotationmark

Basically, operator overload resolution doesn't include implicit user-defined conversions in order to find the operators that could be applicable. From section 7.3.4 of the C# 5 specification: An operation of the form x op y, where op... more 12/8/2015 5:04:49 PM

people

How to convert double value into string value

I want to convert a double value into a string value, but when I am concatenating this string(double) value, it is changing the . to , and I can't manipulate this value. I tried...
Jon Skeet
people
quotationmark

It sounds like your thread has a culture which uses "," as the decimal separator. The simplest approach is probably to call string.Format specifying the invariant culture: Parameters[1] = string.Format( CultureInfo.InvariantCulture, ... more 12/8/2015 10:37:06 AM

people

Multiple executable accessing the same folder at the same time

We have a python application that checks a directory(C:\sample\folder) every 5 seconds, there's also this external application(.net app) that puts file into that same directory...
Jon Skeet
people
quotationmark

It should be fine for the external app to create and write to a file. If the Python app is reading a file, the .NET app may not be able to write to it while Python is reading it, without both processes opening the file in a shareable way,... more 12/8/2015 8:09:39 AM

people

Is it advisable to always use volatile variables with synchronized blocks/methods?

As I understand it, volatile helps in memory visibility and synchronized helps in achieving execution control. Volatile just guarantees that the value read by the thread would...
Jon Skeet
people
quotationmark

I think what you're missing is this from JLS 17.4.4: An unlock action on monitor m synchronizes-with all subsequent lock actions on m (where "subsequent" is defined according to the synchronization order). Which is very similar to... more 12/8/2015 7:10:38 AM

people

Can I reference property comments in constructor comments?

If my class has a commented public property, which is assigned via constructor, can I reference its description from a description of constructor argument with the same...
Jon Skeet
people
quotationmark

You can't include the description, but you can link to the property documentation with the <see> tag. For example: <param name="x">The initial value for <see cref="x"/></param> As an aside, I would strongly urge... more 12/8/2015 6:45:30 AM

people

PostgreSQL : Why "Time" type allocates the same size as "Timestamp"?

Reading about Postgresql data types and specifically about "Date/Time" types i noticed something wierd (For me at least). The "Time" data type allocates the same storage size (8...
Jon Skeet
people
quotationmark

There are 86,400,000,000 microseconds in a day. That's more than 232, so the result can't be stored in 32 bits. The next best option is 64 bits, i.e. 8 bytes. Compare that with the date type which covers 4713BC to 5874897AD, i.e. 5879611... more 12/7/2015 4:43:26 PM

people