You searched for jon skeet. We found 71 results in 0.259 seconds.

Jon Skeet's Edulinq Empty Array Caching

I was going through Edulinq by Jon Skeet, and I came across the following code, Page 23, in which he implements cache mechanism for Empty() operator of Linq private static class...
Jon Skeet
people
quotationmark

My question is, how does this actually cache the Array variable? The CLR caches it per type argument. Basically, EmptyHolder<int> is a different type to EmptyHolder<string> etc, and the type initializer is invoked... more

people

How to convert a list of objects to a JSON object?

I have a HashSet of objects that I am trying to put on a JSON object. HashSet<Users> users; ... JSONObject j = new JSONObject(); j.put("users", users); However,...
Jon Skeet
people
quotationmark

The problem is with your Users class. You appear to be expecting it to just pick up the fields, but I don't believe JSONObject does that - instead, it finds bean-like getters. If you try to convert a single instance of your Users class to... more

people

Sane pattern for immutable pojos and single field changes

Usually I'd love all my POJOs to be immutable (well, to contain only final fields as Java understands immutability). But with my current project, a constant pattern is that I need...
Jon Skeet
people
quotationmark

Yes, that's a fairly common pattern - usually with a bunch of methods with a with prefix. Each with* method "changes" a single field, so you can have: Person jon = new Person("Jon", "Skeet"); Person holly = jon.withFirstName("Holly"); //... more

people

In what way is a static class implicitly abstract?

Jon Skeet, in his book C# in Depth, says about a static class: It can't be declared as abstract or sealed, although it's implicitly both. An abstract class is meant to be...
Jon Skeet
people
quotationmark

What does Skeet mean by a static class being both abstract and sealed? I mean that that's the representation in the IL. For example: static class Foo {} Generates IL of: .class public abstract auto ansi sealed beforefieldinit... more

people

Why the singleton implementation in C# 6.0 does not need the beforefieldinit flag?

I'm trying to understand why this is a correct implementation of the Singleton pattern: public sealed class Singleton : ISingleton { public static Singleton Instance { get; }...
Jon Skeet
people
quotationmark

Both are correct singleton implementations. Whether you need the static constructor just depends on how much you care about full laziness. If you really, really don't want the singleton to be instantiated until it's used by a caller, you... more

people

Passing an array as `params` argument

I have the following method: void MyMethod(params object[] args) { } which I am trying to call with a parameter of type object[]: object[] myArgs =...
Jon Skeet
people
quotationmark

What you've described simply doesn't happen. The compiler does not create a wrapper array unless it needs to. Here's a short but complete program demonstrating this: using System; class Test { static void MyMethod(params object[]... more

people

Wrong time separator for a C# DateTime on Microsoft Azure

if I use this line of code on an azure website DateTime.Now.ToString(new System.Globalization.CultureInfo("it-IT")) the page prints 13/02/2014 12.08.45 but the time...
Jon Skeet
people
quotationmark

I believe it's to do with the version of the CLR being used. On the CLR prior to v4, the culture information being used did have the time separator as .. On CLR v4+, it's :. I don't know why... presumably CLR v4+ is reading the regional... more

people

Optional parameters “must be a compile time constant” with a const still bugging

I've read both Optional parameters "must be a compile-time constant" And Default parameter for value must be a compile time constant? But this keeps not compiling...
Jon Skeet
people
quotationmark

The code you've given has two problems: Optional parameters must come last (apart from params parameters) const fields must be assigned compile-time constants, and string.Empty isn't a const field Because Empty isn't a valid const, your... more

people

How to differenciate a not assigned public int property new instance object from an assigned one

Lets have a simple class with an int property public class SimpleClass { public int myInt { get; set; }// for having a property and not "public int myInt;", see Jon...
Jon Skeet
people
quotationmark

Unless you have code to specifically remember the difference between a property which has been initialized with its default value, and one which hasn't been set at all, you can't tell the difference. I have two suggestions, however: You... more

people

Why is the following Vector code broken exactly?

follows from : Synchronization in Vectors in Java Why is the below code broken as far as synchronization is considered? Is the vector class not synchronized on its own object...
Jon Skeet
people
quotationmark

Is the vector class not synchronized on its own object (this)? Yes, but only for each individual operation. Here we have two operations: if (vector.isEmpty()) vector.add(anElement); It's possible that between the check of... more

people