Browsing 7239 questions and answers with Jon Skeet
No, you can't do it like that. I would suggest something like this instead: // You could do this without the constraint, with a bit of extra work. public class ReadOnlyAfterWrite<T> where T : struct { private T? value; ... more 12/23/2014 9:22:41 PM
Look at this part: public static String [] list={}; { String list [] = {"high", "every", "nearing", "checking", "food ", "stand", "value", "best", "energy", "add", "grand", "notation", "abducted", "food ", "stand"}; } That is... more 12/23/2014 8:48:22 PM
You're creating a Timer instance, but not making sure that it doesn't get garbage collected. From the documentation: After the last live reference to a Timer object goes away and all outstanding tasks have completed execution, the... more 12/23/2014 7:33:16 PM
You can overload the division operator, but: It must always be a binary operator - you've only provider one operand It must always be static At least one of the operand types must be the type you're declaring it in So for... more 12/23/2014 6:02:02 PM
The problem is that the type of myWorker is just AbstractWorker<? extends Task> - in other words, it doesn't know that the type argument is really SpecialTask. It could be an AbstractWorker<SomeOtherTask>, which wouldn't know... more 12/23/2014 5:47:42 PM
You're assigning to a long, but all the arithmetic is being done with int, because every part of the expression (k-(k/2)) * (k/2) is an int. The simplest fix would be to declare k as a long, e.g. long k = s.nextInt(); long value =... more 12/23/2014 5:19:13 PM
program must be running on the main thread without thread Well that's the problem. You're performing an expensive operation (getFromLocation) on the UI thread. Don't do that, basically. You're stopping the UI from being updated... more 12/23/2014 2:45:38 PM
Your CreatePlayer method is an instance method - in other words, it has to be called on an existing instance. You probably want to make it static: public static Player CreatePlayer() You should then remove the Position = new... more 12/23/2014 1:41:42 PM
All the information about the type isn't known beforehand. In your first working snippet, you're telling it on both lines which delegate type you want s => s.Substring(n) to be converted to. In your second snippet, the only place where... more 12/23/2014 12:55:08 PM
I don't think the .NET custom date and time format strings allow that format. You could use my Noda Time project easily enough, using DateTimeOffset.Now if you want the system default time zone to be applied. (It can be done... more 12/23/2014 12:37:09 PM