Browsing 7239 questions and answers with Jon Skeet
Well, you can use Expression.Block to declare a block which contains local variables... For example: using System; using System.Linq.Expressions; public class Test { static void Main() { var x =... more 5/8/2015 11:03:38 AM
No, I don't believe there's anything for this, but it would be dead easy to write an extension method: private static readonly XNamespace ns = "http://www.w3.org/2001/XMLSchema-instance"; public static string NilAwareValue(this XElement... more 5/8/2015 11:01:26 AM
I believe this line is the bug: int bytesWritten = myTransform.TransformBlock (inputBuffer, 0, 4, transformBuffer, 0); You're transforming 4 bytes, regardless of how many bytes you've read. I suspect you want: int bytesWritten =... more 5/8/2015 10:17:09 AM
That's absolutely fine. There is no shared state in either piece of code other than the string literals. As strings are immutable, it's fine for strings to be shared freely between threads, and both string.Format and string.Concat... more 5/8/2015 9:47:12 AM
Your go method assigns a non-null value to "this" instance of ChickYacks - but then creates two new instances of ChickYacks, each of which will have a null value for c. You could: Initialize c in a constructor instead, so that each... more 5/8/2015 7:04:54 AM
What you're describing are generic constraints. Where T:New() == the generic parameter must be a class + have a default empty constructor No, that just says "the type argument must have a parameterless constructor". That actually... more 5/7/2015 7:53:54 PM
If you want to insert a separator between values, string.Join is your friend. If you just want to concatenate the strings, then you can use string.Concat: string assetUrl = string.Concat(assetUrlPieces); That's marginally simpler (and... more 5/7/2015 4:39:26 PM
You could use SimpleDateFormat, but be aware that you should set both the time zone and the locale appropriately: DateFormat formatter = new SimpleDateFormat("HH:mm:ss",... more 5/7/2015 4:35:40 PM
You're writing the content of a binary file to the response. We don't know what else you've written to the response, or what you've set the content type to. If your response content type is text/plain or something similar, then that's the... more 5/7/2015 4:09:22 PM
If I understand right, in the above example the classloader will load the Map and List classes before MyClassThatUsesMap. You don't understand right. Imports have nothing to do with execution-time handling. They only affect how the... more 5/7/2015 2:01:37 PM