Browsing 7239 questions and answers with Jon Skeet
I would suggest that you make each XMLFilePersisting use the specific concrete type, but then combine the results into a List<ITransferable>. For example: // Names changed to be more conventional var class1Loader = new... more 2/7/2015 9:01:43 AM
Yes, autoboxing works to convert int to Number just as well as from int to Integer: public class Test { public static void main(String[] args) throws Exception { foo(10); foo(10.5); foo(10.5f); ... more 2/7/2015 8:37:32 AM
You can't just call a method in a class declaration like that. You can declare fields in a class declaration, but method calls (other than those used for field initializers) have to be in methods or constructors. For example: import... more 2/7/2015 8:25:11 AM
Firstly, it really helps if you indent more clearly: var xml = new XElement("root", lines.Where((line, index) => index > 0) // Skips first line .Select(line => new XElement("TEST", line.Split(',') ... more 2/6/2015 5:27:30 PM
However, it seems if I multiply two ulongs together and it results in an overflow, I end up with zero instead of the "modulus(ulong.max)" of whatever I would have otherwise. You wouldn't get the result modulus(ulong.max) - you would... more 2/6/2015 2:51:45 PM
Basically you need a way of extracting lines from a TextReader. Here's a simple solution which will only iterate once: public static IEnumerable<string> ReadLines(this TextReader reader) { string line; while ((line =... more 2/6/2015 12:21:51 PM
By default, overflow checking is turned off in C#. Values simply "wrap round" in the common way. If you compiled the same code with /checked or used a checked { ... } block, it would throw an exception. Depending on what you're doing,... more 2/6/2015 9:28:18 AM
In the integer version, the compiler knows that all the data in the number 5 can be stored in a byte. No information is lost. That's not always true for floating point values. For example, 0.1f isn't equal to 0.1d. Now for the example,... more 2/6/2015 8:28:59 AM
Your question isn't entirely clear to me, but it sounds like you basically need to look in typeof(T) with reflection. Fortunately, dynamic typing in C# means you can get the compiler team to do the hard work - admittedly at execution... more 2/6/2015 8:08:29 AM
Since I already used the : operator, how do I do that? : isn't an operator - you're just using it in the generic type constraint. You can still specify an interface to implement. This should be fine: public class... more 2/5/2015 9:55:09 PM