Hi, is it possible to declare a delegate inside a routine?
E.g
private void MySub()
{
delegate int oAddMe(int n1, int n2);
}
Or can delegates only be declared with a global scope inside the
class.......
public class MyClass {
delegate int oAddMe(int n1, int n2);
private void MySub()
{
// Code....
}
}
Thanks in advance
Mark 4 1684
Only within a class or globally...declaring a delegate within a method
doesn't really make much sense since a delegate is a type. What specifically
are you trying to achieve?
"Mark" <ma*******@n0Sp8mTAIRAWHITIdotAC.NZ> wrote in message
news:I0********************@news.xtra.co.nz... Hi, is it possible to declare a delegate inside a routine?
E.g
private void MySub() { delegate int oAddMe(int n1, int n2); }
Or can delegates only be declared with a global scope inside the class.......
public class MyClass {
delegate int oAddMe(int n1, int n2);
private void MySub() { // Code.... } }
Thanks in advance Mark
Hi Daniel, thanks for your response.
I was just wondering, since we can use delegates to "point" to a function, I
was just thinking that we should be able to define a "Pointer" inside a
routine (Much like we can in C++).
I was just curious ;)
Thanks again
Mark
"Daniel O'Connell [C# MVP]" <onyxkirx@--NOSPAM--comcast.net> wrote in
message news:O%***************@tk2msftngp13.phx.gbl... Only within a class or globally...declaring a delegate within a method doesn't really make much sense since a delegate is a type. What
specifically are you trying to achieve?
"Mark" <ma*******@n0Sp8mTAIRAWHITIdotAC.NZ> wrote in message news:I0********************@news.xtra.co.nz... Hi, is it possible to declare a delegate inside a routine?
E.g
private void MySub() { delegate int oAddMe(int n1, int n2); }
Or can delegates only be declared with a global scope inside the class.......
public class MyClass {
delegate int oAddMe(int n1, int n2);
private void MySub() { // Code.... } }
Thanks in advance Mark
"Mark" <ma*******@n0Sp8mTAIRAWHITIdotAC.NZ> wrote in message
news:xp********************@news.xtra.co.nz... Hi Daniel, thanks for your response.
I was just wondering, since we can use delegates to "point" to a function, I was just thinking that we should be able to define a "Pointer" inside a routine (Much like we can in C++).
Ahh, I see. Well, delegates are full fledged types, so they need to be
accessible globally to be of much use(A type defined in a method would be
useless everywhere except in that method. And if you aren't leaving the
method there is considerably less need for type definition).
I was just curious ;)
Thanks again Mark
"Daniel O'Connell [C# MVP]" <onyxkirx@--NOSPAM--comcast.net> wrote in message news:O%***************@tk2msftngp13.phx.gbl... Only within a class or globally...declaring a delegate within a method doesn't really make much sense since a delegate is a type. What specifically are you trying to achieve?
"Mark" <ma*******@n0Sp8mTAIRAWHITIdotAC.NZ> wrote in message news:I0********************@news.xtra.co.nz... > Hi, is it possible to declare a delegate inside a routine? > > E.g > > private void MySub() > { > delegate int oAddMe(int n1, int n2); > } > > Or can delegates only be declared with a global scope inside the > class....... > > public class MyClass { > > delegate int oAddMe(int n1, int n2); > > private void MySub() > { > // Code.... > } > } > > Thanks in advance > Mark > >
Hi Daniel, cool, thanks for your help
Cheers
Mark
"Daniel O'Connell [C# MVP]" <onyxkirx@--NOSPAM--comcast.net> wrote in
message news:eH*************@TK2MSFTNGP12.phx.gbl... "Mark" <ma*******@n0Sp8mTAIRAWHITIdotAC.NZ> wrote in message news:xp********************@news.xtra.co.nz... Hi Daniel, thanks for your response.
I was just wondering, since we can use delegates to "point" to a
function, I was just thinking that we should be able to define a "Pointer" inside a routine (Much like we can in C++). Ahh, I see. Well, delegates are full fledged types, so they need to be accessible globally to be of much use(A type defined in a method would be useless everywhere except in that method. And if you aren't leaving the method there is considerably less need for type definition).
I was just curious ;)
Thanks again Mark
"Daniel O'Connell [C# MVP]" <onyxkirx@--NOSPAM--comcast.net> wrote in message news:O%***************@tk2msftngp13.phx.gbl... Only within a class or globally...declaring a delegate within a method doesn't really make much sense since a delegate is a type. What specifically are you trying to achieve?
"Mark" <ma*******@n0Sp8mTAIRAWHITIdotAC.NZ> wrote in message news:I0********************@news.xtra.co.nz... > Hi, is it possible to declare a delegate inside a routine? > > E.g > > private void MySub() > { > delegate int oAddMe(int n1, int n2); > } > > Or can delegates only be declared with a global scope inside the > class....... > > public class MyClass { > > delegate int oAddMe(int n1, int n2); > > private void MySub() > { > // Code.... > } > } > > Thanks in advance > Mark > >
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Michael C |
last post by:
Hi all,
Is there an easy way to get the parameters of an asynchronous delegate call
from the callback function? Here's an example of what I'm trying to do:
private delegate ArrayList...
|
by: N8 |
last post by:
I am trying to get an exception to occur and consequently found that when
adding a target method to a delegates invocation list, a copy of that object
is added instead of a reference to the object....
|
by: Richard MSL |
last post by:
I have an application in managed C++, and a method in C# that I call. But now
I want to add the ability to tell the C# method a specific method in my C++
assembly to call back to. For example, to...
|
by: Quimbly |
last post by:
I'm having some problems comparing delegates. In all sample projects I
create, I can't get the problem to occur, but there is definitely a problem
with my production code.
I can't give all the...
|
by: lothar.behrens |
last post by:
Hi,
I am thinking about the delegate mechanism and try to understand it. I
am coming from
C++ and know about callbacks or member callbacks.
In C++ I have this typedef for every class that...
|
by: Flomo Togba Kwele |
last post by:
I have a class which processes for a relatively long time. I want to enable
other classes which call this one to receive process messages if they wish.
The called routine (the one defining the...
|
by: Deckarep |
last post by:
Hey all,
I pass my methods to be called into my function by Delegate.
Once inside my function which invokes them I'd like to get the orignal
name of the delegate if possible. I just want the...
|
by: =?Utf-8?B?UmljaGFyZEBub3NwYW0ubm9zcGFt?= |
last post by:
I'm trying to declare CreateFile as an extern from the dll like so:
....
using System.Runtime.InteropServices;
internal static extern IntPtr CreateFile(
String filename,
UInt32...
|
by: Tony Johansson |
last post by:
Hello!
Below I have two different alternativ for where to declare the delegate
DoCalculate.
Is it possible to say something generally where to declare the delegate.
Is best within the class or...
|
by: DolphinDB |
last post by:
Tired of spending countless mintues downsampling your data? Look no further!
In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
|
by: Vimpel783 |
last post by:
Hello!
Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
|
by: jfyes |
last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
|
by: ArrayDB |
last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
|
by: PapaRatzi |
last post by:
Hello,
I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
|
by: Defcon1945 |
last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
|
by: Shællîpôpï 09 |
last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
|
by: af34tf |
last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome former...
| |