Browsing 7239 questions and answers with Jon Skeet

Linq does not contain the definition for 'Where'

I'm trying to adjust my query through an if statement as shown below: IQueryable articles = null; if (User.IsInRole("Admin")) { articles =...
Jon Skeet
people
quotationmark

Your articles variable is using the non-generic type IQueryable, which supports very little indeed. You want IQueryable<T> for a suitable <T>. For example: IQueryable<Article> articles; // Initialize as before I'd... more 3/31/2014 4:46:58 PM

people

trying to find range of long data type in java

trying to verify range of long in java.. why is this program not working? it gives infinite loop (probably). i'm not getting output at the command line and the cursor keeps...
Jon Skeet
people
quotationmark

Your program will work eventually - but it's got to perform 263 iterations (in each direction) first. That's going to take a very long time. Long.MAX_VALUE and Long.MIN_VALUE are rather simpler ways of finding this out. Or just look at JLS... more 3/31/2014 10:39:40 AM

people

Class implementing interface containing same interface

I can't think of a reason why I shouldn't do this but I wanted to see if I was missing something. If I have a class that implements an interface is there any reason not to have...
Jon Skeet
people
quotationmark

That's absolutely fine, and is often used for delegation, e.g. in the decorator pattern. While it's not actually using interfaces (instead using an abstract base class, Stream), BufferedStream is an example of this. Or for example you... more 3/31/2014 9:18:16 AM

people

Extract time from String

I have this string which is a result of net time \SERVER_NAME command in cmd : Current time at \SERVER_NAME is 3/31/2014 9:35:57 AM The command completed...
Jon Skeet
people
quotationmark

Obtaining a remote time of day... If you're trying to talk to machines with multiple cultures - and if the culture of the system on which you're running may vary as well - I would strongly advise that you avoid this text-based... more 3/31/2014 8:47:16 AM

people

Inheritance from an Interface

I have an interface at the top of my program (IVehicle), below this is a class which implements the majority of the inherited methods (Vehicle). Below Vehicle is two more...
Jon Skeet
people
quotationmark

The whole point of an interface is that it represents a level of abstraction - you're saying "All types that implement this interface support these operations." It sounds like the operations of "change the fuel field" simply don't belong... more 3/30/2014 8:59:10 PM

people

Arrays and Linked List : will arrays be able to allocate 300MB in memory if 512 MB is free but 300 MB is not contiguous

I have a conceptual question regarding arrays and linked lists. Arrays are a contiguous block of memory. Suppose a system has 1024 units of memory. 512 units are occupied...
Jon Skeet
people
quotationmark

Well, it's somewhat implementation-specific, but I'd expect a JVM implementation to initialize arrays by allocating one contiguous block of memory. I don't think it's absolutely required, but it's going to be by far the most efficient... more 3/30/2014 7:49:58 PM

people

Synchronous use of DownloadStringTaskAsync on UI thread

This is one of these things where I thought that I knew exactly what is happening, but have been unable to figure how to fix it on Windows Phone 8. I want to have two methods...
Jon Skeet
people
quotationmark

Yes, you're currently creating a deadlock. You're using async/await, which means that when the task returned by DownloadStringTaskAsync completes, a continuation will be scheduled to continue loadAsync from where it left off, and back in... more 3/30/2014 7:39:49 PM

people

Classpath error on Mac OS

I made a Java application which runs another Java code using the java -cp "xxx.jar;xxx.jar" net.minecraft.client.main.Maincommand. The ; (or :depending on the OS) between the two...
Jon Skeet
people
quotationmark

It's not clear what you meant by "I tested forcing usage of ; even on Mac OS" but basically you should use the right path separator for the platform when you run the new Java process. So on Windows you'd want: java -cp... more 3/30/2014 5:39:26 PM

people

Can't get this Tic Tac Toe Game to play fair (Part2)

Ok after rearranging me logical approach of this tic tac toe game I was able to clean a few bugs except the biggest one. Why is the AI rewriting the user selection. I have tried...
Jon Skeet
people
quotationmark

Your "AI" consists of this line: int num = rNum.nextInt(8); That's just picking one of 8 (why not 9?) squares at random, with no checking whether or not the space is already taken. If you really want to just pick a random space, you... more 3/30/2014 5:26:11 PM

people

TCP socket.receive() seems to drop packets

I am working on client-server appliction in C#. The comunication between them is with TCP sockets. The server listen on specific port for income clients connection. After a new...
Jon Skeet
people
quotationmark

my problem is when sometimes the client send 2 messages one after another, the server doesn't receive the second message I think it's much more likely that it does receive the second message, but in a single Receive call. Don't... more 3/30/2014 4:42:07 PM

people