Browsing 7239 questions and answers with Jon Skeet
A Func doesn't have a result until you call it. So GetGridCell doesn't have a value of type GridCell - it's a function which can be called to get a GridCell. For example: Func<int, Type, GridCell> function = GetGridCell; GridCell... more 3/14/2016 6:52:33 AM
I was under the impression that static initialization is thread safe by default. Is that correct? Yes, in terms of initialization - unless you use reflection to call the type initializer again, etc. Of course, there can then be... more 3/13/2016 8:53:17 AM
I suspect the exception doesn't actually happen on the line you've indicated, but later, in System.arraycopy. The problem is that your call to Array.newInstance passes in the array type, when you only want to pass in the element type. In... more 3/12/2016 9:48:47 PM
To join multiple conditions together, you need each to be an actual condition - so I think you want: --where:cat==Category1||cat==Category2 Or more readably IMO: "--where:cat == Category1 || cat == Category2" The quoting may be... more 3/11/2016 1:40:39 PM
It's public so that the GetEnumerator() method can be declared to return it. That then allows the C# compiler to use it in a foreach loop... avoiding any heap allocations because List.Enumerator is a struct. (A mutable struct, which makes... more 3/11/2016 11:56:39 AM
Well, you've selected the child element - so you just need to select its parent: xDoc.Root .Elements("WebService") .Elements("Name") .Where(node => node.Value == "Name1") .Select(node => node.Parent) ... more 3/11/2016 11:01:52 AM
You can't do so by writing to the same file - but you can easily do it to a different file, just by reading a chunk of characters at a time in one encoding and writing each chunk in the target encoding. public void RewriteFile(string... more 3/11/2016 7:04:25 AM
You're calling ExecuteNonQuery, despite trying to execute... a query. You should be using ExecuteScalar - or ExecuteQuery and check whether there are any results. ExecuteNonQuery is specifically for insert/delete/update SQL statements,... more 3/10/2016 10:09:23 PM
Basically, unbound receivers allow you to use instance methods as if they were static methods with a first parameter of the declaring type - so you can use them as functions by passing in whatever instance you want. With a bound receiver,... more 3/10/2016 11:17:03 AM
I suggest you just keep a list or array of the values to test against: private static final List USER_ROLES_TO_SAVE = Arrays.asList( StaticValues.LUMEN_SELECT_USER_ROLE, StaticValues.EASY_SENSE_USER_ROLE, ... more 3/10/2016 7:04:09 AM