Browsing 7239 questions and answers with Jon Skeet
You just need the right XName value - I'd use this: doc.Root.SetAttributeValue(XNamespace.Xml + "space", "preserve"); The XName +(XNamespace, string) operator is generally the simplest way to work with namespaces in LINQ to XML, in my... more 3/7/2016 2:32:44 PM
This is the problem: if ((newUser.Username == a) && (newUser.Password == b)) okFlag = true; else okFlag = false; That code is run for every entry in the file. So if the okFlag is set to true from the first entry, but... more 3/6/2016 7:23:07 PM
Disposing of an object doesn't do anything magical - the CLR doesn't really care about IDisposable at all... it's just a framework interface that has support within C# (and other languages). Calling Dispose is just like calling other... more 3/6/2016 9:42:20 AM
It looks like you just need to find the relevant Table element, then append a new Row element to that. For example, using LINQ to XML, assuming there is only one Table element: var doc = ...; // XDocument.Load or whatever var table =... more 3/6/2016 9:28:41 AM
What am I misunderstanding in assuming that it should compile? You're not reading the spec :) Basically, conditional operator requires that either the second and third operands are of the same type, or that there's an implicit... more 3/4/2016 1:28:50 PM
Just use the TimeZoneInfo.DisplayName property: var zone = TimeZoneInfo.Local; // For example Console.WriteLine(zone.DisplayName); Or for your precise example: var zone = TimeZoneInfo.FindSystemTimeZoneById("SE Asia Standard... more 3/4/2016 11:00:29 AM
Yes, this is type erasure being annoying. It's worth looking at what you get in bytecode here: class Car {} interface IService<T> { void create(T obj); } class CarService implements IService<Car> { public void... more 3/4/2016 9:58:01 AM
LINQ has operations to project a sequence using indexes, but this isn't built into the query expression syntax, so you have to use "regular" extension method calls to start with. After that it's fairly easy, although probably just as... more 3/4/2016 7:27:03 AM
The type inference in Test1 means it's calling msgProcessor.CanProcess<RRMessage>() ... whereas in Test2 it's calling msgProcessor.CanProcess<IBaseMessage>() Now RRMessageProcessor doesn't implement... more 3/3/2016 11:22:15 PM
The other answers have shown you how to append a single string to a text file. If you naturally have a collection of lines, however, you probably want File.AppendAllLines: File.AppendAllLines(@"C:\Users\****\Desktop\File.txt", array); more 3/3/2016 7:09:18 PM