Actually, I re-read the MSDN stuff on delegates, and I think I'm getting the
hang of them. A delegate IS a function form, and you can create instances of
a delegate that are associated with a function of that form that executes
that function. Now one can pass a pointer to the delegate, and this is
equivalent to passing a 'function pointer' of the original function.
Did that make sense?
"Peter Oliphant" <poliphant@RoundTripInc.com> wrote in message
news:%23XiSdfryFHA.904@tk2msftngp13.phx.gbl...[color=blue]
> Ok, cool, and thanks! I should use 'delegates'. However, since I've never
> even heard of a 'delegate' before, could you give me an idea HOW to use
> them? : )
>
> And what's wrong with function pointers and managed code? So far it seems
> managed stuff doesn't support many things, like 'const', 'static', etc,
> and
> now function pointers? It seems like a whole new language should create
> instead of trying to keep managed and unmanaged together if there are so
> many incompatibilities between the two. I like managed stuff, but the more
> I
> use it the more I keep falling into 'traps' (stuff I think should work
> (since it does in unmanaged code) that generates errors)...
>
> PS - I looked 'delegates' up in the on-line MSDN, but it doesn't seem to
> say
> anything remotely like about how to pass a function of a given form to a
> method (and I NEED to PASS different functions, I can't just hard code
> each
> case, there are an inifinte number of such cases!).
>
> "Jochen Kalmbach [MVP]" <nospam-Jochen.Kalmbach@holzma.de> wrote in
> message news:uAu%23NAryFHA.2652@TK2MSFTNGP14.phx.gbl...[color=green]
>> Hi Peter![color=darkred]
>>> Here is a simplification of my code. Basically, I have a class (A) that
>>> can be constructed using a function pointer to a function that returns a
>>> bool with no parameters. I then want to create an instance of this class
>>> (A) in another class (B) which uses one of its own methods of the
>>> 'proper form' to initialize the instance. But I get an error:[/color]
>>
>>
>> For managed code you should use a delegate!!!
>> And no function pointers...
>>
>> --
>> Greetings
>> Jochen
>>
>> My blog about Win32 and .NET
>>
http://blog.kalmbachnet.de/[/color]
>
>[/color]