Browsing 7239 questions and answers with Jon Skeet
It's the same as for any type: the default value for that type. (So the same as you'd get in a field which isn't specifically initialized.) The default values are specified in JLS 4.12.5: For type char, the default value is the null... more 2/25/2016 7:04:38 AM
You'll want to use the final result whether there's a discount or not, so you should have a variable for it whether there's a discount or not. If there isn't a discount, just set the value of the variable to the original. In fact, I would... more 2/25/2016 6:47:47 AM
You're trying to look in a namespace with a URI of "s" - it doesn't have that URI. The URI is "http://schemas.xmlsoap.org/soap/envelope/". I'd also suggest avoiding XName.Get and just using XNamespace and the XName +(XNamespace, string)... more 2/24/2016 3:50:12 PM
Your suggested second nullity check isn't good enough either, as the first call to get() could return a non-null value, and the second call could return null. I'd suggest: for (WeakReference<Subscriber> subRef : subscribers) { ... more 2/24/2016 3:46:59 PM
This has nothing to do with the using statement, and everything to do with the while loop. Leaving everything else aside, this is the problem, in essence: string myVar; while (someNonConstantCondition) { myVar = someValue; } return... more 2/24/2016 3:40:32 PM
It sounds like what you really want is to accept a Func<Symbol, DataLine>, or possibly a Func<Symbol, int>. Although at that point, you don't really need a method, given how trivial (and value-free) that method would be using... more 2/24/2016 2:53:07 PM
it seems that placing the "sqlConn" into the using statement is making it dispose automatically Yes, that's what the using statement is for. How can I prevent this? I'd prefer not to open and close the connection manually each... more 2/24/2016 11:36:57 AM
You don't need local variables for this - either for the individual SqlParameters or the values. Your code would be simpler as: public void InsertProduct(int categoryId, string name, string description, decimal price) { String sc =... more 2/24/2016 8:18:53 AM
You're using your random number generator differently in the two cases. In your encryption code, you generate one random number, and use it for all characters: Random rng = new Random(key); int randomNum = rng.nextInt(256); while... more 2/24/2016 7:02:31 AM
This is the problem: while(true) { ServerSocket s = new ServerSocket(2345); pipe = s.accept(); ... } You're trying to bind to the same port repeatedly. All you need to do is create a single ServerSocket and call accept on it... more 2/23/2016 8:48:29 PM