Juan,
What you have isn't able to be assigned any function from CSomeClass, it
has to have the specific signature that takes a CString and returns a bool.
In .NET you want to use a delegate. For example, to take a string and
return a boolean, you have the generic Predicate<Tdelegate, which is
defined as:
// Item might not be the actual parameter name.
delegate bool Predicate<T>(T item);
If you had a class like this:
public class MyClass
{
public bool DoSomething(string item)
{
// Return some boolean value based on item.
return item.Length 10;
}
}
You could then code this:
MyClass myClass = new MyClass();
Predicate<stringdel = myClass.DoSomething;
You could then pass around del and call it like a method anywhere you
wish.
--
- Nicholas Paldino [.NET/C# MVP]
-
mv*@spam.guard.caspershouse.com
"Juan Dent" <ju******@nospam.nospamwrote in message
news:FD**********************************@microsof t.com...
Hi,
I need the equivalent of a pointer to a member function (as used in C++)
but
in C# 2.0. I know it must be a special way of using delegates but don't
know
how to make the function associated with the delegate capable of accessing
the private parts of the class.
For example, in C++ one would have:
typedef bool (CSomeClass::*TAGTEXTFUNC)( CString &rstr );
so that we could assign any method of CSomeClass to TAGTEXTFUNC, and be
able
to access private parts of CSomeClass. How can one accomplish this in C#?
--
Thanks in advance,
Juan Dent, M.Sc.