Browsing 7239 questions and answers with Jon Skeet
Instance field initializers run after the superclass constructor has been called. So the order of execution is: Call to new B() Start to initialize instance of B: Implicitly call super() Start to initialize the instance with respect to... more 6/26/2017 5:04:13 AM
You're only calling Read once, which certainly isn't guaranteed to read all the bytes. You could either loop, calling Read and copying the relevant number of bytes on each iteration, or you could use Stream.CopyTo: var imageStream = new... more 6/25/2017 1:36:45 PM
The question is vague and badly worded IMO. There's no such concept as a variable "going out of scope" in C# - but there is the scope of a variable, and the scope of the i variable is the whole of the foreach loop body, including the empty... more 6/24/2017 8:04:29 AM
Firstly, I almost certainly wouldn't take the approach below. I'd either convert the input to a List<long>, or just use the code you've already got, at least until I'd absolutely proved that it wasn't good enough. However, as this... more 6/23/2017 5:28:23 PM
LINQ to XML makes this reasonably easy if some assumptions are met: There are no elements with "triple duplication" e.g. <TestData><TestData><TestData>. I'm sure it's feasible to work around that, but it's trickier. We... more 6/23/2017 4:04:33 PM
This has nothing to do with arrays really. Your comparison is equivalent to: Object x = Integer.valueOf(3); Object y = Byte.valueOf((byte) 3); boolean equal = x.equals(y); That's never going to return true. Even though your original... more 6/23/2017 2:01:15 PM
You're trying to use T as a type argument, so the compiler needs to know which T you mean. Chances are you want to make your method a generic method too. Fixing the name to follow conventions (and be more readable in general) at the same... more 6/22/2017 10:17:19 AM
The example you were quoting from uses LINQ to Objects, where the implicit lambda expressions in the query are converted into delegates... whereas you're using EF or similar, with IQueryable<T> queryies, where the lambda expressions... more 6/21/2017 4:19:47 PM
The only way to do this would be to fill in the optional parameter with a value of the appropriate type, so that the compiler knows which overload to pick. For example: public IEnumerable<JobsViewModel> GetJobsViewModels( Guid... more 6/21/2017 10:31:49 AM
You're calling the WebProxy(string, int) constructor - where the string is meant to be a host name, not a URI. You should call the WebProxy(string) constructor, at which point the string is a URI. If you need to specify a non-default... more 6/21/2017 7:26:26 AM