Browsing 7239 questions and answers with Jon Skeet
If you want to save it in a file, don't use DownloadString to start with - just use WebClient.DownloadFile. If you really want to fetch it in memory and then save it, you can save it with: File.WriteAllText(filename, results); Note... more 9/20/2013 11:51:35 AM
You haven't shown us the XML involved, but I strongly suspect the problem is that you're not specifying the namespace. You probably want something like: XNamespace ns = "some namespace URI"; XDocument doc = XDocument.Load("uri"); var... more 9/20/2013 11:36:11 AM
That construct is an object initializer. It's not a list of arbitrary statements - it's only initialization of fields and properties, and they're comma-separated: Foo x = new Foo // Implicitly calls the parameterless constructor { ... more 9/20/2013 11:21:11 AM
I just don't know what codes should i use to swap the data of numTens and numHundred without using extra variables You shouldn't, basically. Just take the simple route of a temporary variable: int[] tmp = numTens; numTens =... more 9/20/2013 8:49:42 AM
The simplest approach is to use MethodInfo.IsDefined - quite possibly with LINQ as well: var testMethods = from assembly in assemblies from type in assembly.GetTypes() from method in type.GetMethods() ... more 9/19/2013 9:32:16 PM
Firstly, it's worth being aware that this really has very little to do with static. There's no such thing as a "static object" - there are just objects, and there are fields and methods which may or may not be static. For example, there... more 9/19/2013 12:09:31 PM
From the docs for Serializable: Classes that require special handling during the serialization and deserialization process must implement special methods with these exact signatures: private void writeObject(java.io.ObjectOutputStream... more 9/19/2013 11:13:17 AM
It would be very hard to do this in a completely general way, but one option would be to extract the relevant DateTimeFormatInfo that you're interested in (using CultureInfo.DateTimeFormat), extract the culture-specific patterns from that... more 9/19/2013 10:13:54 AM
You don't need to cast at all, assuming the value of properties[i] is already actually the right type: for (int i = 0; i < items.Length; i++) { typeof(BugManagerQueryOptions).GetProperty(items[i].ToString()) ... more 9/19/2013 8:40:50 AM
It's specified in section 12.4.2 of the JLS, which gives details of class initialization: Next, execute either the class variable initializers and static initializers of the class, or the field initializers of the interface, in textual... more 9/19/2013 8:06:22 AM