Browsing 7239 questions and answers with Jon Skeet

Async and await difference between console, Windows Forms and ASP.NET

I have been educating myself on async / await use and I think I understood under-the-hood concept. However, most of Channel 9 tutorials, MSDN articles and Stack overflow answers...
Jon Skeet
people
quotationmark

Since, in UI thread based application, the UI thread is always available (unless the process is stopped explicitly or by Windows), so the ThreadPool thread responsible for executing the code after "await" in any async method, will... more 12/24/2013 7:16:13 PM

people

Change Java object type?

During the runtime of my programme, I would like to identify the type of an Object I would need to instantiate. As an example: If a user is travelling from A to B, he can choose...
Jon Skeet
people
quotationmark

They would have a common set of methods, ie: "move", but their implementation would be different. That sounds like they should both implement the same interface or extend the same abstract superclass then. Use that interface or... more 12/24/2013 6:51:35 PM

people

Do we need to package Newtonsoft JSON.Net dll file along with main application in order to make it work in non visual studio systems?

I have a DLL project that will be used by WinForms application. I have used NewtonSoft JSON.NET for JSON deserialization. Newtonsoft.Json.dll Newtonsoft.Json.xml Now, My...
Jon Skeet
people
quotationmark

It's not a matter of whether you've got VS.NET installed - it's a matter of whether you've got Json.NET in the right place. It's a third party library that you depend on, so you should ship it with your app. Personally I would copy it... more 12/24/2013 6:47:15 PM

people

How do you check to compare a string value to each element in an array?

So I have a String Array (sConsonantArray) and have all of the consonants stored in it. String[] sConsonantArray = new String[]...
Jon Skeet
people
quotationmark

It seems to me that it would be simpler to have the consonants as a string and then use charAt: private static final String CONSONANTS = "bcdfgh...z"; if (CONSONANTS.indexOf(word.charAt(word.length() - 2)) { ... } If you really... more 12/24/2013 6:38:06 PM

people

Get hash of a String as String

I'm here: String password = "123"; byte passwordByte[] = password.getBytes(); MessageDigest md = MessageDigest.getInstance("SHA-512"); byte passwortHashByte[] =...
Jon Skeet
people
quotationmark

I want to convernt this numbers to one String which contains the hash-code as plaintext. The hash isn't plain-text. It's binary data - arbitrary bytes. That isn't plaintext any more than an MP3 file is. You need to work out what... more 12/24/2013 6:33:59 PM

people

What is basic Difference Between Type.GetType() and Type.GetElementType()

I can understand the Type.GetType() 's Scenario which the Object's type will be got, but what is Type.GetElementType() and what does it do? Can anyone explain it in a clear way?
Jon Skeet
people
quotationmark

Type.GetElementType is used for arrays, pointers, and by-ref parameter types. For example: object value = new int[100]; Console.WriteLine(value.GetType()); // System.Int32[] Console.WriteLine(value.GetType().GetElementType()); //... more 12/24/2013 11:52:03 AM

people

How invoke method for a method by default value for parameters by reflection

I have need to invoke a method by default value parameters. It has a TargetParameterCountException by this message : Parameter count mismatch var methodName = "MyMethod"; var...
Jon Skeet
people
quotationmark

You can use ParameterInfo.HasDefaultValue and ParameterInfo.DefaultValue to detect this. You'd need to check whether the number of arguments you've been given is equal to the number of parameters in the method, and then find the ones with... more 12/24/2013 11:15:27 AM

people

.net c# string to DateTime GMT+0 or UTC (from any/unknown format)

I need to parse and add to database dates from RSS feed. There's a problem, that one has "Wed, 08 May 2013 17:03:44 EDT", other with EST, other with CET, other "Mon, 23 Dec 2013...
Jon Skeet
people
quotationmark

I don't believe there's anything in the .NET framework which will parse time zone abbreviations - and for fairly good reason, given that they're not globally unique. It's a shame that RSS used such a brain-dead date/time format, to be... more 12/24/2013 11:04:27 AM

people

Add information to interface

Connect.java public interface Connect { void commit(); void close(); void setTransactional(); void executeCommand(); } MainApp.java public class MainApp { public static...
Jon Skeet
people
quotationmark

One simple answer is to have your own implementation of Connect which either exposes an isTransactional property, or which automatically commits when it's transactional, delegating everything else to an underlying connection: public class... more 12/24/2013 10:57:27 AM

people

Linqtoxml filtering not working

I am fallowing a tutorial on the internet I use xml file this .I think missed out something .Because Nothing happens Just a blank page appears.What I am doing wrong again.How can...
Jon Skeet
people
quotationmark

You're currently looking for elements in the unnamed namespace - whereas the file you've linked to has a namespace URI of "http://www.adventure-works.com" for the elements you're looking for. Just use: XNamespace aw =... more 12/24/2013 10:48:39 AM

people