Browsing 7239 questions and answers with Jon Skeet

'Console' does not contain a definition for 'ReadKey' in asp.net 5 console App

I am creating a Simple application in ASP.NET 5 Console in VS2015 CTP. For the below line of code // Wait for user input Console.ReadKey(); I am getting error...
Jon Skeet
people
quotationmark

Basically, Console.ReadKey is available in the full framework, but isn't available in .NET Core. That's why it's saying it's "Available" for ASP.NET 5.0 (building against the full framework) but "Not available" for ASP.NET Core 5.0... more 6/2/2015 6:04:00 AM

people

Return results from executor in java

I need some help retrieving results from executors. The place where I create the workers: public static void method() { double bestProb = 0; double best p1 =...
Jon Skeet
people
quotationmark

(This answer was provided when the question was at revision 1. The OP is editing the question in response to the answer, which makes the answer make less sense - rather than me try to keep up with the edits, please refer to revision 1 to... more 6/2/2015 5:54:54 AM

people

Adding "de" to es ES CultureInfo DateTime C#

Probably dumb question, but I haven't worked with Culture a whole bunch before. The assets for the date need to be: MMMM dd "de" yyyy (w/o quotes on the "de"). junio 1 de...
Jon Skeet
people
quotationmark

Just quote the literal part with single quotes, double-quotes, or escape each character with a backslash: string date = DateTime.Now.ToString("MMMM dd 'de' yyyy", ci); string date = DateTime.Now.ToString("MMMM dd \"de\" yyyy", ci); string... more 6/1/2015 2:10:06 PM

people

Do you remove the data:image/jpeg;base64, before decoding Base64 string using C#?

I'm trying to convert a Base64 encoded string that was generated from a re-sized image from the canvas element and I'm getting the following error when converting using the...
Jon Skeet
people
quotationmark

do I need to strip off the prefix of data:image/jpeg;base64, and then decode the remainder? Yes - the prefix isn't base64-encoded text, it's just saying that the rest is base64-encoded (and what the mime-type is). We don't know... more 6/1/2015 12:52:51 PM

people

Why does type promotion take precedence over varargs for overloaded methods

public class Test { public static void printValue(int i, int j, int k) { System.out.println("int"); } public static void printValue(byte...b) { ...
Jon Skeet
people
quotationmark

JLS 15.12.2 is the relevant bit of the spec to look at here. In particular - emphasis mine: The remainder of the process is split into three phases, to ensure compatibility with versions of the Java programming language prior to Java... more 6/1/2015 12:34:43 PM

people

Cannot access closed file during Reading/Writing operation C#

I have searched the internet and viewed many posts, but none has helped me. So I decided to ask my own question over here. I am writing some data to binary file when the save...
Jon Skeet
people
quotationmark

What is causing the file to be closed at this point? Your call to R.Close() in writeDGVrowListToBinaryFile. You shouldn't be closing the writer in that method. You almost never want to close a file handle (or other disposable... more 5/31/2015 9:09:35 AM

people

Java GregorianCalendar Fields

I try to convert a String to GregorianCalendar, and then check it. Below, I post my codes. I really confuse that why the fields seem wrong. Thanks a lot for help. public class...
Jon Skeet
people
quotationmark

These: System.out.println(date.DAY_OF_MONTH); System.out.println(date.MONTH); System.out.println(date.YEAR); Should... more 5/30/2015 5:55:01 AM

people

Unexpected Values In LinkedList Java

I am getting weird return in memory for my linked list. I'm not sure what the cause is... After the code iterates through the database and attempts to put my data into the list......
Jon Skeet
people
quotationmark

You want to create a new instance of Property for each record. Currently you've got this Property prpty = new Property(); ... outside the loop, so your linked list consists of many references to the same object. That line should be... more 5/30/2015 4:51:25 AM

people

Java or C# equivalent of Python freezegun or Ruby timecop

I want to test highly time dependent applications written in Java or C#. Is there a Java or C# equivalent of Python freezegun or Ruby timecop?
Jon Skeet
people
quotationmark

You don't need a separate library to do testing of time-based code - you just need to treat "the current time provider" as a dependency like you would anything else. So avoid calls to new Date(), Calendar.getInstance() etc in Java, and... more 5/30/2015 4:46:50 AM

people

How does the ternary operator evaluate the resulting datatype?

Given this piece of code public class Main { public static void main(String[] args) { foo(1); foo("1"); foo(true?1:"1"); foo(false?1:"1"); ...
Jon Skeet
people
quotationmark

Isn't the return type for a ternary expression evaluated at runtime? No, absolutely not. That would be very contrary to the way Java works, where overload resolution etc is always performed at compile-time. What would you expect to... more 5/29/2015 4:16:15 PM

people