Browsing 7239 questions and answers with Jon Skeet
If your XML file literally contains WHEN a < 0 then I'm not surprised you're getting an exception - that's not valid XML. It's got nothing to do with the SQL side of things as your attempted fix suggest. You should be escaping the <... more 11/6/2015 8:29:58 AM
Simpler code for the "building a dictionary" that Serge shows: use LINQ's lookup, DateTimeZone.GetUtcOffset, and Offset keys instead of TimeSpan values: var now = SystemClock.Instance.Now; var provider = DateTimeZoneProviders.Tzdb; var... more 11/6/2015 7:06:07 AM
You're asking to assign a sequence value to single entity variable. That's like trying to do this: // Won't work for the same reason string name = new List<string> { "foo", "bar" }; If you're just trying to find out whether there... more 11/6/2015 6:53:15 AM
I don't know why this program just work twice.. Because the default HTTP connection pool has a size of 2 connections per host - and you're using them both up. You can configure this with the <connectionManagement> element in... more 11/5/2015 4:50:04 PM
The short answer is: C# type inference and support for method group conversions has improved over time. You're still using the C# 3 compiler (which is what shipped in VS 2008). The exact details are tricky, and I can never remember exactly... more 11/5/2015 2:01:28 PM
You're effectively testing for the number of tasks that have actually started and got as far as incrementing the counter. That takes a little while - so basically you're creating all 8 tasks and starting them, then they're incrementing the... more 11/5/2015 1:46:41 PM
We can't tell terribly easily, but the name globalZaehler2 makes it sound like this is a field, not a local variable. Using a field for an "index" variable in a for loop is almost always a bad idea... I can't remember the last time I... more 11/5/2015 12:27:28 PM
It makes sense if the compiler infers one type and you want to specify another. It doesn't make sense otherwise. For example, suppose you have an IEnumerable<string> and want to create a List<T>... if you want a... more 11/5/2015 12:08:16 PM
It sounds like you need: An interface or abstract base class with the GetSpecialCase method A generic method (with type parameters for both input and output) of List<TResult> GetData<T, TResult>(T item) where T :... more 11/5/2015 7:21:24 AM
As of C# 5, it would definitely be better to get the compiler to bake this into the call site instead, using [CallerMemberName] public void Log(string message, [CallerMemberName] caller = null) { } Then: public void DoSomething() { ... more 11/4/2015 5:39:40 PM