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

Casting to custom type, Enumerable.Cast<T> and the as keyword

This is more a question out of curiosity than necessity and came about having had to deal with Active Directory (MS) types such as SearchResultCollection (in the...
Jon Skeet
people
quotationmark

Semantically I find this a little weird, since the extension method is called cast.. Shouldn't it be casting? It's casting each element if it needs to, within CastIterator... although using a generic cast, which won't use explicit... more

people

Why does Contains() return false but wrapping in a list and Intersect() returns true?

Problem: When I use Contains() against an IEnumerable<T> of classes that correctly implement IEquatable and override GetHashCode it returns false. If I wrap the match...
Jon Skeet
people
quotationmark

Okay - the problem is actually in the array implementation of ICollection<T>.Contains. You can see that simply like this: static void Main(string[] args) { var ab = new MyEquatable("A", "B"); var target = new... more

people

How can I get a hash of the body of a method in .net?

I'd like to generate a hash of a method body or entire class in order to compare it to a previous hash and therefore detect changes at run-time. I've seen reference to this being...
Jon Skeet
people
quotationmark

You can use MethodInfo.GetMethodBody() to get a MethodBody, then create a hash based on whatever you like (e.g. the IL byte array) using whatever kind of hash you want (e.g. SHA-256). Of course, it's possible for the IL to change without... more

people

Lambda parameter conflicting with class field on accessing field in later scope

I've got a weak imagination when it comes to names, so I often find myself re-using identifiers in my code. This caused me to run into this specific problem. Here's some example...
Jon Skeet
people
quotationmark

I raised Roslyn issue 2110 for this - the C# 6 spec is changing to allow this. Mads Torgersen has indicated that the change is by design: The rule was well intended, in that it was supposed to minimize the risk of "moving code around"... more

people

Is it possible to dynamically specify the type of event when using AddHandler?

I am trying to write a clever little function here that will add a specified delegate as an event handler to all the controls in a collection for any dynamic event. What I'm...
Jon Skeet
people
quotationmark

Two options: Specify a "subscription delegate" via a lambda expression. I wouldn't like to guess at what this would look like in VB, but in C# it would be something like: (control, handler) => control.MouseEnter += handler; Then... more

people

HashSet.IntersectWIth using a custom IEqualityComparer produces wrong results in Mono

I'm having in issue where a certain piece of code is running as expected in .NET 4.0 but not in Mono 2.6 (in Unity3D). Please have a look: void Test() { ...
Jon Skeet
people
quotationmark

I suspect that it's just a matter of MemberInfo.Equals not working as you expect. That's easy to test: var m1 = get("x"); var m2 = get("x"); Console.WriteLine(m1.Equals(m2)); If that prints False, then that's the issue, and you should... more

people

Why Does This Queryable.Where Call Change the Queryable's Type Parameter?

Code to Reproduce Issue I ran into a situation where an IQueryable.Where<TSource> call was returning an IQueryable<TOther> where TOther != TSource. I put together...
Jon Skeet
people
quotationmark

Why does this happen? Because the Where call is receiving a type argument of ParentQueryElement as TSource. It creates a result based on TSource as a new object... so you end up with something which "knows" about ParentQueryElement... more

people

Double encryption / decryption fails but single does not AES 256 bit

So this particular exception is pretty common, yet my problem is slightly different from what is usually asked. I've got a AES decrytpion and encryption function defined as...
Jon Skeet
people
quotationmark

You're using the wrong keys for decrypting. You're encrypting with key B, then encrypting the result with key A. You're then trying to decrypt that result with key B, and the final result with key A. Each time you decrypt, you should be... more

people

Cannot parse xml from Yahoo! Fantasy Sports with c#

I did some searching around the web and could not find the cause of my problem so I apologize if that has already been asked in another form I just did not understand. My problem...
Jon Skeet
people
quotationmark

This is what's tripping you up: xmlns="http://fantasysports.yahooapis.com/fantasy/v2/base.rng" You're asking for elements in the unnamed namespace - but the elements default to the namespace shown above. It's easy to fix that in LINQ... more

people

Unable update file store in appdata scope 500 Internal Server Error

Previously, I have a set of Google Drive API code, which works fine in the following scenarios Save new file to appdata Update previous file in appdata Save new file to...
Jon Skeet
people
quotationmark

Note: please do not treat this as an "official answer from Google". Although I work at Google, I don't work on the Drive API. I've reproduced the problem, and reported it to the Drive API team, who may be able to provide more details. In... more

people