I have a php page that calls and runs a method called pagestart() in a class called construct. Later in that same page I call a different method in a different class. If that different method errors for any reason I would like to have it call the error() function in the construct class.
My question is is there a way to call the error() ...
I have a form that starts a thread. Now I want the form to auto-close when this thread terminates.
The only solution I found so far is adding a timer to the form and check if thread is alive on every tick. But I want to know if there is a better way to do that?
Currently my code looks more less like this
partial class SyncForm : Form ...
I want to imitate a normal python list, except whenever elements are added or removed via slicing, I want to 'save' the list. Is this possible? This was my attempt but it will never print 'saving'.
class InterceptedList(list):
def addSave(func):
def newfunc(self, *args):
func(self, *args)
print 'savi...
How can I count the number of objects of a class type within a method of that class? For that matter, how to do it outside of a class without adding the objects to a list?
I should have thought of that! Thanks! I'm gonna leave it unanswered for a little while to see if there is a better way, because I agree. I'm just sortv wrapping my h...
I have a class Referrals. When you create an object in the class, it checks that the input strings are unique (and therefore never allows duplicate objects). But when I find that input string str1 is equal to that of a previously created object, instead of creating a new object or just returning false, i want to change a property of the ...
Per MSDN, the "new" keyword when used for method hiding only suppresses a warning.
http://msdn.microsoft.com/en-us/library/435f1dw2.aspx
Do I really need this "new" keyword to perform method hiding? If I have a child class that has the same method name but doesn't explicitly state that it is overriding, isn't that the same thing ess...
Hi there...
We've all read excessively long methods or functions, where
your eyes end up bleeding when you reach the return statement.
We've also seen those one-liner functions that seem pointless...
I just wanted to ask: which do you think is the best average length for a function/method?
Having into account that every language has it...
So I recently ran into this C# statement at work:
public new string SomeFunction(int i)
{
return base.SomeFunction(i);
}
I searched the web but I think I can find a better answer here.
Now, I'm guessing that all this does is return a new string with the same value as the string returned by the call to base.SomeFunction(i)... ...
Do you really need this keyword to overload methods? What is the difference between using the overloads keyword vs. just having different method signatures?
...
I have two separate lists of entities:
class EntityCollection : IList<Entity>
{
//...
}
EntityCollection Foo;
EntityCollection Bar;
I want to implement an operation to move an object Qux that is on list Foo to Bar. What's the best way to implement it?
As a MoveTo instance method on EntityCollection:
public void MoveTo(EntityCo...
Is it possible to reflect upon a chain of method calls to determine at what point you are in the chain of calls?
At the very least, is it possible to discern whether a method is the last call in the chain?
$instance->method1()->method2()->method3()->method4()
Is it possible to do the same using properties that return instances of obje...
I'm trying my hand at some iPhone programming and I've run across something that may be fairly obvious to veterans but I'm not exactly sure why it's happening. I have two UIViewController classes, and I want to access a method from the other class. I have two NSObject classes associated with both of them in IB (with the Class file as U...
Is there any way to do this in one line?
$arr = $foo->getBarArray();
return $arr[0];
This throws an error:
return $foo->getBarArray()[0];
...
Say I have an object called FieldEdit. I define the function constructor for this object, instantiate it via. var obj = new FieldEdit(), and define its methods by FieldEdit.prototype.<method name> = function() { ... }.
Under what situations would calling this object's methods within the objects' other methods (via. this.<method name>()...
I would like to be able to detirmine the return type of my method call at runtime, but I can not seem to be able to get the Type of T.
public <T> T getT()
{
Object t = null;
Class<?> c = t.getClass();
System.out.println(c.getName());
return (T) t;
}
Is there any way to determine the Type of T at runtime in Java?
...
I have two view controllers (viewControllerA and viewControllerB) with their own views. When the user touches a button in the view of viewControllerA, I am able to load the view of the viewControllerB.
However, I don't know how to invoke a method in viewControllerB's class!
...
I need to find all the methods in a class that accept a set of parameters in a specific order, some of them are generics (Collection).
The example on the Sun web site only works with non generic classes:
http://java.sun.com/docs/books/tutorial/reflect/member/methodInvocation.html
cheers in advance
...
I have a small app that uses cocos2d to run through four "levels" of a game in which each level is exactly the same thing. After the fourth level is run, I want to display an end game scene. The only way I have been able to handle this is by making four methods, one for each level. Gross.
I have run into this situation several times ...
Can you give me an example?
...
I want to generate a list of all methods in a class or in a directory of classes. I also need their return types. Outputting it to a textfile will do...Does anyone know of a tool, lug-in for VS or something which will do the task? Im using C# codes by the way and Visual Studio 2008 as IDE
...