Browsing 7239 questions and answers with Jon Skeet
Two issues: You're raising the event whether or not anyone has subscribed to it. Don't do that - you will get a NullReferenceException if you call WriteLog(this, e) when WriteLog is null. In C# 6 it's easy to avoid... more 12/15/2016 12:55:24 PM
I don't want a solution that involves private variables in the class, it has to stay inside the method. But the value is part of the state of the object (or type, for a static method) - so it makes sense for it to be a field declared... more 12/15/2016 12:21:15 PM
The problem is with your SQL, which I've reformatted here to avoid a single huge line: SqlCommand cmd = new SQlCommand( @"insert into finalinstructoreexpense (sonvinid,particulars,amount,totalamt,date, ... more 12/15/2016 9:56:33 AM
All you're seeing is a race condition between writing to System.out and System.err. You're explicitly calling System.out.print with 1, then 3, then 4, then 2, and the exception is being thrown and dumped to System.err automatically. So... more 12/15/2016 9:41:42 AM
You can't. The whole point of the conditional ?: operator is that it evaluates an expression. You can't even just use: Foo() ? Bar() : Baz(); ... because that isn't a statement. You have to do something with the result... just like when... more 12/14/2016 3:59:31 PM
You can't, as myMethod is an instance method, and you can't access anything to do with the instance being created within the constructor initializer. This would work though: public class PresenceLookup : LookupScript { public... more 12/14/2016 8:23:22 AM
When you write XNamespace ns = "xsi"; That's creating an XNamespace with a URI of just "xsi". That's not what you want. You want a namespace alias of xsi... with the appropriate URI via an xmlns attribute. So you want: XDocument doc =... more 12/14/2016 7:25:39 AM
Scanner is trying to load a file - and you're providing an absolute filename, /res/words.txt. In order to create an InputStream, you're loading a resource, giving it an absolute resource name, even though you've called the variable... more 12/13/2016 3:23:36 PM
It sounds like you're looking for SkipWhile from LINQ: test = test.SkipWhile(x => x != "three").ToList(); That will skip everything until (but not including) the "three" value, then include everything else. It then converts it to a... more 12/13/2016 9:15:11 AM
You haven't provided full code, but I suspect you're invoking Enumerable.Concat<char>, a generic extension method provided by System.Linq.Enumerable, extending IEnumerable<T>. This is valid because string implements... more 12/10/2016 5:35:29 PM