Browsing 7239 questions and answers with Jon Skeet
Yes, the last line uses a narrowing conversion, which is why a cast is necessary. The example is used to demonstrate that the widening conversion on the middle line loses information, that's all: This program prints -46 thus indicating... more 6/30/2015 5:27:10 PM
To use BinaryFormatter, you'll need to create serializable classes to match the data in your JSON. So for example: // I'm hoping the real names are rather more useful - or you could use // Json.NET attributes to perform... more 6/30/2015 4:25:18 PM
Why does y1.f(y2) calls the f() method in A instead of in B? Because the compile-time type of y1 is A. Overloading is performed at compile-time... the execution-time type of the object you call the method on is only relevant for... more 6/30/2015 3:03:30 PM
Ugly as that is, it doesn't sound too hard using string.Join to create the appropriate text contents. After fetching the relevant data - which I assume you know how to do - you could just use something like: var records = ...; // The... more 6/30/2015 2:51:10 PM
Is it correct, that the Equals(object obj) method below will never be called with an instance of type Entry? No. Consider: object entry1 = new Entry(...); object entry2 = new Entry(...); bool equal = entry1.Equals(entry2); The... more 6/30/2015 12:26:54 PM
It's just an attribute, like any other - the usage of the attribute is up to whatever decides to use it. It's relatively rare to see attributes for return, but it's entirely legal, and it's just metadata which can be examined by... more 6/30/2015 6:25:48 AM
The problem is that the compiler you're using is from Java 5 or later, so it's using StringBuilder instead of StringBuffer - but the execution environment you're using appears to be Java 1.4.2, which doesn't include StringBuilder. Note... more 6/30/2015 6:18:30 AM
Assuming you're just trying to write the text to a file, it's not clear why you're writing it to a MemoryStream first. You can just use: var js = new DataContractJsonSerializer(typeof(T), _knownTypes); using (var stream =... more 6/30/2015 6:14:39 AM
It works both ways, but I want to know which is better to use. Well that entirely depends on what you're trying to achieve. If you want to create a new, entirely independent instance, do so. But it's more common that you want to use... more 6/30/2015 6:01:57 AM
Some comments have suggested leaving it in JSON format and storing it in a text column. I'd suggest that if you have control over your schema, you should store it in two NUMERIC fields - one for latitude, and one for longitude.... more 6/30/2015 5:44:27 AM