Browsing 7239 questions and answers with Jon Skeet
If the original datasource is already accessible by index, such as for a list or an array, you can just use indexArray.Select as Matt showed. If you've got an IEnumerable<T> instead, you can use the Where overload which provides the... more 4/24/2017 4:45:01 PM
There's some confusion here... parts of the LHS of the assignment operator are evaluated first. In particular, the expressions df and 0 will be evaluated before GetLearningIndex, but the array element assignment (including index... more 4/24/2017 8:12:35 AM
You have more problems than you think. You're currently relying on the timer ticking exactly once per second. Don't do that - instead, use a System.Diagnostics.Stopwatch to measure the elapsed time, and then update the display by... more 4/24/2017 7:45:05 AM
They definitely create the same kind of value - unlike if you call Array.CreateInstance and create an array with a non-zero lower bound, for example. However, they're not the same in terms of IL - the first is simply a method call, the... more 4/24/2017 6:18:56 AM
You can write a method to use the caller-information attributes: // Put this anywhere public static string GetCallerName([CallerMemberName] name = null) => name; Importantly, when you call this, don't supply an argument: let the... more 4/23/2017 11:57:41 AM
TL;DR: You're right to be concerned about the use of the system local time zone, but you should have been concerned earlier in the process, when you used the system local time zone to construct a Date in the first place. If you just want... more 4/22/2017 6:36:01 AM
Instead of using timeZoneName, I'd suggest using timeZoneId, which will be an IANA ID such as Europe/London. You then have various options: Find a mapping from that to Windows time zone IDs yourself, e.g. with TimeZoneConverter Use Noda... more 4/21/2017 1:48:04 PM
It looks like you don't need CryptoConfig at all. You just need MD5: using (var md5 = MD5.Create()) { var hash = md5.ComputeHash(Encoding.UTF8.GetBytes(password)); return BitConverter.ToString(hash); } The MD5 class is present... more 4/21/2017 1:12:36 PM
You're currently deserializing it as a list of dictionaries, when you only actually want a single dictionary. There may be a cleaner way of doing this, but you can deserialize it as a list of key-value pairs, then convert that into a... more 4/21/2017 10:38:24 AM
If you call typeInfo.GetType(), you will indeed get the execution-time type of the objec that typeInfo refers to - so some concrete type derived from TypeInfo. You want TypeInfo.AsType(): Returns the current type as a Type... more 4/20/2017 3:15:23 PM