Browsing 7239 questions and answers with Jon Skeet
The time zone ID "Eastern Standard Time" doesn't actually mean "Eastern Standard Time". It really means "Eastern Time"... From TimeZoneInfo.Id: The value of the Id property is usually, but not always, identical to that of the... more 6/12/2014 2:01:32 PM
If you can use LINQ to XML, it's simple: var results = doc.Descendants() .Where(x => x.Name.LocalName.StartsWith("Store") || x.Name.LocalName.StartsWith("SS")); With XmlDocument it's... more 6/12/2014 1:56:59 PM
This would be more efficient with sets, but even just with lists, it's simple to use retainAll: // Start by copying arrayList1 List<Integer> result = new ArrayList<Integer>(arrayList1); result.retainAll(arrayList2); That's... more 6/12/2014 1:44:20 PM
I think you want GetOrAdd, which is explicitly designed to either fetch an existing item, or add a new one if there's no entry for the given key. var collection = result.GetOrAdd(someKey, _ => new... more 6/12/2014 1:22:22 PM
No - in order to override a method, you have to derive from it, which you can't do when the class is sealed. Basically, you need to revisit your design to avoid this requirement... more 6/12/2014 1:07:30 PM
You can create a UTF8Encoding instance which doesn't use the BOM, instead of using Encoding.UTF8. using (TextWriter sw = new StreamWriter(file, false, new UTF8Encoding(false))) { doc.Save(sw); } You can save this in a static field... more 6/12/2014 1:03:35 PM
I don't know of anything built into LINQ, but it's really easy to create your own: public static IEnumerable<T> RepeatIndefinitely<T>(this IEnumerable<T> source) { while (true) { foreach (var item in... more 6/12/2014 10:06:09 AM
There's an Any overload which accepts a predicate, so you just need to use that: bool exists = Tree.Elements("Order") .Elements("City") .Any(x => x.Value == "City2"); Alternatively, use Where... more 6/12/2014 10:03:17 AM
Basically, you should return a List<Personen> or some similar collection type. (Consider declaring the return type as IList<Personen> or IEnumerable<Personen> and using List<Personen> as the implementation... more 6/12/2014 9:49:44 AM
I suspect you just need to change the return type of the method: public static Variable<?> createVariable(String type) That basically says, "I'm returning a variable of some type, but I have no information about what the type... more 6/12/2014 9:18:12 AM