Browsing 7239 questions and answers with Jon Skeet
Precedence isn't about ordering operations - it's about binding operations together. The execution order is always left to right. So for example, if you write: int a = x * (y / z); then x is still evaluated before y / z. So in this... more 9/17/2013 4:52:00 PM
Instead of saving it to a file, save it to a MemoryStream. Then you can use: string base64 = Convert.ToBase64String(stream.ToArray()); And to write the original binary data to a file: using (var output = File.Create(filePath)) { ... more 9/17/2013 1:49:11 PM
These are ISO-8601 period values (not points in time) - and Joda Time handles them fine: import org.joda.time.*; import org.joda.time.format.*; public class Test { public static void main(String[] args) { String startText =... more 9/17/2013 1:01:13 PM
You'd be better off using a BufferedReader and readLine. That will be more efficient in terms of IO, and means you don't need to worry about handling the line breaks yourself: BufferedReader reader = new BufferedReader(readDat); String... more 9/17/2013 8:42:01 AM
There's a very significant difference between: JFrame frame = new JFrame(); and frame = new JFrame(); The first version declares a new local variable (in the context you've given) and assigns it a value. That local variable is... more 9/17/2013 6:12:45 AM
Can anyone please help me to know about the functionality of this code. Sure. The very first thing that happens is that the class is initialized as per section 12.4.2 of the JLS. This involves running the static initializers of the... more 9/17/2013 6:04:15 AM
My understanding is that when I instansiate a new instance of Class A, all variables in the class scope would be set to their default values. No. Only instance variables. Your value variable in A is a static variable. The fact that... more 9/16/2013 8:16:35 PM
They'll just get garbage collected. That's fine - you don't need to worry about them. In particular, even though Task implements IDisposable you basically don't need to dispose of them. See Stephen Toub's blog post on the topic for... more 9/16/2013 6:59:49 PM
In terms of why it's a bad idea: It isn't really an alias. Anywhere that doesn't let you use the implicit conversions won't work pleasantly with this. You're using a class, which means you need to allocate an extra object every time you... more 9/16/2013 6:39:36 PM
I think you're confused by what Func<T, TResult> is meant to be. The first parameter (T) is the input to the delegate; TResult is the output. So you probably want: Func<Appointment, DateTime> appointmentFunction = x =>... more 9/16/2013 5:45:32 PM