Browsing 7239 questions and answers with Jon Skeet
I have a String, which contains the byte array's String value. This is unclear to start with. If you've converted binary data to text, how have you done that? That should guide you as to how you convert back. For example, if you've... more 11/7/2013 11:36:54 AM
Well you can call it by reflection, yes - using MethodInfo.MakeGenericMethod to provide the type arguments: var method = typeof(Whatever).GetMethod("UpdateAndSave"); var genericMethod =... more 11/7/2013 11:24:06 AM
The question is: can I somehow make CLR put object's constructor into a try block? No. Or rather, it's pointless to do so, from a resource management perspective. If an exception is thrown by the constructor, then there won't be a... more 11/7/2013 9:02:21 AM
I have a zip file and after decoding it I get a byte array now I want to create a FileInputStream object with that byte[] object. But you don't have a file. You have some data in memory. So a FileInputStream is inappropriate -... more 11/7/2013 7:12:04 AM
You can't just project an array like that. You effectively have to loop - although you don't need to do that manually in your own code. LINQ makes it very easy, for example: RateInfos[] rt = hr.Select(x => x.RateInfo).ToArray(); Or... more 11/7/2013 7:00:48 AM
But the problem is in the database instead of \n a new line is getting stored. Well it sounds like the string itself probably contains a newline. If you write: String x = "a\nb"; in Java, then that is a string with 3... more 11/7/2013 6:57:11 AM
You can subtract one DateTime from another using the - operator (or use the Subtract method) to get a TimeSpan, then use TimeSpan.TotalHours: DateTime start = new DateTime(2000, 1, 1, 0, 0, 0); DateTime end = new DateTime(2000, 1, 1, 0,... more 11/6/2013 7:43:58 PM
Maybe this question is stupid, but why does simply changing the order of the elements affects the result? It will change the points at which the values are rounded, based on their magnitude. As an example of the kind of thing that... more 11/6/2013 6:56:32 PM
But what would be the harm in making my code snippet legal? Surely there has to be a harm for a practice to become illegal? It's confusing code - you can simplify the code by just catching IOException, whereas it looks like you really... more 11/6/2013 5:47:51 PM
No, you should specify an encoding using InputStreamReader - BufferedReader doesn't let you specify the encoding. For ASCII files you're likely to be okay with the platform default encoding (most defaults are compatible with ASCII), but... more 11/6/2013 5:15:15 PM