Здравствуйте, mikа, Вы писали:
M>Здравствуйте, Nekto_2004, Вы писали:
M>Delegate. И member — это не только метод.
[msdn]
The declaration of a delegate type establishes a contract that specifies the signature of one or more methods. A delegate is an instance of a delegate type, and references one or more of the following:
A target object that is not a null reference (Nothing in Visual Basic) and an instance method of the target object
A static method
.... When a delegate references an instance method, the delegate stores a reference to the method's entry point and a reference to an object, called the target, which is the class instance that the method is invoked on. The target of an instance method cannot be a null reference (Nothing). When a delegate references a static method, the delegate stores a reference to the method's entry point. The target of a static method is a null reference (Nothing).
[/msdn]
А если мне не известен этот target object? А известен только member, который я буду вызывать. А target object будет известен позже. Что делать? Короче, хочу как в C++, иметь pointer to member(я понимаю, что это не только метод) — далее хочу пробежаться по какой-то коллекции конкретных instancов и вызвать этот pointer to member. Как это сделать с помощью делегатов, я не знаю. Плиз, подскажите, как. Спасибо.