Browsing 7239 questions and answers with Jon Skeet

No overload for method `destroyAfterCBEvent' takes `0' arguments

Error: No overload for method destroyAfterCBEvent' takes0' arguments What is the solution of above problem??? Chartboost.CBManager.didFailToLoadInterstitialEvent +=...
Jon Skeet
people
quotationmark

You're calling destroyAfterCBEvent, when you actually want to use a method group conversion to create a delegate to subscribe to the event. You need to take the brackets off (which is what makes it a method call). You... more 5/21/2014 5:54:41 AM

people

How to use Linq to check if a list of strings contains any string in a list

I'm constructing a linq query that will check is a string in the DB contains any of the strings in a list of strings. Something like. query = query.Where(x => x.tags ...
Jon Skeet
people
quotationmark

EDIT: This answer assumed that tags was a collection of strings... It sounds like you might want: var list = new List<string> { ... }; var query = query.Where(x => x.tags.Any(tag => list.Contains(tag)); Or: var list = new... more 5/20/2014 3:41:19 PM

people

When is a .NET assembly unloaded?

We know that a .NET assembly is loaded at the last possible moment - when you enter a method that references a something in the foreign assembly. When is an assembly unloaded? Is...
Jon Skeet
people
quotationmark

It's only unloaded when the AppDomain that it's loaded into is unloaded, e.g. as part of a web app recycling. Any classes within the assembly stay loaded while the assembly is loaded, so therefore they stick around until the AppDomain is... more 5/20/2014 3:04:47 PM

people

Interfaces can't be instantiated but is this an exception

I'm very surprised after seeing that I actually have to Instantiate an Interface to use the Word Interoop in C#. Microsoft.Office.Interop.Word.Application word = new...
Jon Skeet
people
quotationmark

It's because it's a COM interface. COM interfaces - and only COM interfaces - can be instantiated directly. The runtime will create an instance of the real type behind the scenes. Personally I think it's a bit ugly (and I can't find any... more 5/20/2014 2:58:15 PM

people

Thread 1 is executing in java synchronized method 1, can Thread 2 then execute in java synchronised method 2?

Was wondering if someone could help clear this up for me. (Student) Say we have two threads, "Thread1" & "Thread2". If Thread1 is executing in method 1 can Thread2 then...
Jon Skeet
people
quotationmark

There isn't a monitor associated with a specific method - there's a monitor associated with an object. So if you're trying to synchronize on the same object in both methods, the second thread will block until the first thread releases the... more 5/20/2014 2:42:55 PM

people

Why can I assign 0.0 to enumeration values, but not 1.0

Just out of curiosity: why can I assign 0.0 to a variable that is of an enumeration type, but not 1.0? Have a look at the following code: public enum Foo { Bar, ...
Jon Skeet
people
quotationmark

It's a bug that you can use 0.0. The compiler implicitly treats all constant expressions with a value of zero as just 0. Now, it's correct for the compiler to allow an implicit conversion from a constant int expression of 0 to your enum... more 5/20/2014 2:28:18 PM

people

how can I return a subclass reference from superclass method

I have a superclass method which returns itself(for builder pattern). This class has several subclasses , so I want to return a reference to actual(subclass) type of the object....
Jon Skeet
people
quotationmark

There's no particularly nice way of doing this, that I'm aware of. The best I've seen is just to cast - which you can do once, of course: public class Superclass<T extends Superclass<T>> { @SuppressWarnings("unchecked") ... more 5/20/2014 2:03:49 PM

people

LINQ , How to get Max ID with "where" condition

I have searched on stack overflow, but find example for max ID only , I want to find Max ID for some particular condition. Something like this var nRow = from p in...
Jon Skeet
people
quotationmark

Well if you really like query expressions, you can express the "filter and projection" and then use the Max extension method: var query = from p in ctx.FormControls where p.FormObjectsId == FormID select p.ID; var... more 5/20/2014 1:51:11 PM

people

How to assign one Action Listener to a couple of buttons?

button1.addActionListener(new ActionListener(){ @Override public void actionPerformed(ActionEvent ae) { exite.setEnabled(true); ...
Jon Skeet
people
quotationmark

Just assign the ActionListener to a different variable first: ActionListener listener = new ActionListener() { ... more 5/20/2014 1:27:51 PM

people

"Constructor call must be the first statement in a constructor" getting error in Java code?

I am getting two errors in this code Constructor call must be the first statement in a constructor. Implicit super constructor Parent() is undefined. Must explicitly invoke...
Jon Skeet
people
quotationmark

There are four things you need to understand: If you don't specify any explicit constructor call, the compiler inserts a call to super() for you. There must be exactly one constructor call for any constructor- either explicit or the... more 5/20/2014 1:03:02 PM

people