Browsing 7239 questions and answers with Jon Skeet

.StartsWith and .Contains are returning null when comparing dates

In my application, I was trying to pull out the sum of values in a specific column for a specific period of time. For example if I want it to pull the sum for every month I did...
Jon Skeet
people
quotationmark

Without trying to work out exactly this fails, I would strongly recommend not using string representations for this sort of thing anyway. Just use DateTime comparisons instead - assuming that DateApproved is a DateTime column, of course.... more 3/13/2015 6:34:47 PM

people

Error When installing NuGet package 'Microsoft.AspNet.Http.Extensions 1.0.0 beta3'

When installing 'Microsoft.AspNet.Http.Extensions 1.0.0-beta3' I get this. I am trying to use it for iappbuilder reference so I can create an app with my app. Any ideas what could...
Jon Skeet
people
quotationmark

That package only has aspnet50 and aspnetcore50 directories within the lib directory. This means it's only suitable for ASP.NET vNext projects. You can't use it within a regular .NET 4.5 project - yet, at least. If you're not using... more 3/13/2015 5:33:06 PM

people

Constant value cannot be converted to int

I can't see why line#5 fails to compile whereas line#4 is ok. static void Main(string[] args) { byte b = 0; int i = (int)(0xffffff00 | b); // ok int j =...
Jon Skeet
people
quotationmark

Compile-time constants are checked differently to other code, basically. A cast of a compile-time constant into a type whose range doesn't include that value will always fail unless you explicitly have an unchecked expression. The cast is... more 3/13/2015 5:27:50 PM

people

Something is wrong with my code

I am making a music maker program in C# (visual studio). Here is my code: int accCount = 0; enum accidental { flat, sharp, none } accidental thisAcc = accidental.none; if...
Jon Skeet
people
quotationmark

Well yes, look at this code (reformatted from your question for readability): object key(int count, accidental ac) { return key(0, accidental.none); } That will just invoke the same method... which will invoke the same method...... more 3/13/2015 4:37:39 PM

people

Cannot get this property name using this code and expression api

I have the following class and I need to get its property names: public class PMLButtonData { public int BackgroundColorID { get; set; } public...
Jon Skeet
people
quotationmark

The problem is the type of your expression tree - you're trying to represent a delegate of type Func<T, object>, and if the property returns an int, that means it would need to be converted. You just need to make the method generic... more 3/13/2015 1:48:19 PM

people

What is the purpose of Escape Sequence \' in java?

if I print ' (single quote) in the System.out.println() I can get exact output. Like : System.out.println("test'test"); output: test'test What is the purpose of using \'...
Jon Skeet
people
quotationmark

It's for use in character literals: char c = '\''; Without that, it would be painful to get a single apostrophe as a char. more 3/13/2015 1:42:21 PM

people

Why does joining 5 threads at once result in simultaneous activity?

Thread.new{sleep rand(0..10}; puts '#1 done'}.join Thread.new{sleep rand(0..10}; puts '#2 done'}.join Thread.new{sleep rand(0..10}; puts '#3 done'}.join Thread.new{sleep...
Jon Skeet
people
quotationmark

My understanding is that map will go through each item in the array and execute the Thread#join method on each one in turn... which is exactly what my first code example does. No, it isn't. The first code starts a thread, then joins... more 3/13/2015 1:38:58 PM

people

How to bit shift and concatenate to get correct result?

I'm currently struggling with modbus tcp and ran into a problem with interpreting the response of a module. The response contains two values that are encoded in the bits of an...
Jon Skeet
people
quotationmark

I already tried to (logically) bit-rightshift r[0] by 8, but then the upper bits get lost because they are stored in the first 8 bits of r[1]. Well they're not "lost" - they're just in r[1]. It may be simplest to break it down step... more 3/13/2015 1:33:58 PM

people

iOS : Timezone Issue on Local timezone of iPhone device

I have been working on an application that takes dates from server in a certain format as given below. "2015-02-03 00:00:00" I want to show them with different UI format...
Jon Skeet
people
quotationmark

The simplest approach would be to parse it as if it were UTC - making it always valid, and without ever needing DST adjustments - and then format it in UTC as well. In other words, set the time zone of both the formatter and parser to UTC.... more 3/13/2015 11:14:44 AM

people

Do not include weekends in date time

I just want to know on how to compute DateTime without including weekends (currently making a library system). The library is not open during weekends that is why i need to...
Jon Skeet
people
quotationmark

There are far more efficient ways of doing this for large numbers of days, but if your code is only ever going to deal with small values, you can just use: static DateTime AddDaysExcludingWeekends(DateTime start, int days) { // Do you... more 3/13/2015 10:52:23 AM

people