Browsing 7239 questions and answers with Jon Skeet
Well you can use list.ElementAt(i) to get the ith element in the order they happen to be returned by the dictionary - but there's no guarantee as to what order that is, or that it will stay consistent over time. I would strongly recommend... more 12/10/2014 3:56:35 PM
It seems to me that you just need a regular expression: using System; using System.Text.RegularExpressions; public class Test { static void Main() { ExtractFirstNumber("Event: 1 - Some event"); ... more 12/10/2014 12:12:19 PM
Basically you've updated the assembly - the objects in your session are from the "old" assembly, and you can't cast to a type in the "new" assembly, as types are tightly bound to their originating assembly. Options: Be prepared to throw... more 12/10/2014 11:43:27 AM
You don't have any UTF-8 here - and UTF-8 doesn't have an endianness anyway, as its code unit size is just a single byte. Your code would be simpler as: var bytes = File.ReadAllBytes(@"file.wav"); string base64 =... more 12/10/2014 10:44:57 AM
In the first case, you have a value of type Nullable<int>, which is "the null value for the type". The Nullable<T> type is a value type with two fields, like this: public struct Nullable<T> where T : struct { private... more 12/10/2014 9:35:20 AM
For all but the casting part, you can just use: object newInstance = Activator.CreateInstance(car.Color.GetType()); If that will always implement a particular interface or have a particular base class, you could cast to that - but you... more 12/10/2014 9:21:37 AM
You're printing out a java.util.Date (the result of calling getTime()). A Date doesn't include time zone information at all - Date.toString() always displays the point in time represented by that Date in the default time zone. Basically,... more 12/10/2014 7:45:17 AM
If you're after the count of the value elements, you can just use: var count = IdList.Count(); if (count > 1) { ... } Or if you don't need the count afterwards, you can just see whether there are any left after you've skipped... more 12/9/2014 6:48:17 PM
Your code is effectively: bool CheckExisting() { // Some setup code for (int i = 0; i < fCount; i++) { // Code which isn't terribly relevant return ...; } } Now the C# 5 language specification section... more 12/9/2014 2:49:15 PM
Question: In the call itemC.equals(itemB), why the equals method of Object class is getting called. Because the compile-time type of itemC is Object. Overriding is performed at execution time based on the actual type of the target... more 12/9/2014 2:01:45 PM