473,763 Members | 3,820 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to test if a delegate or event is empty

In C# is very easy:

if(myDelegate== null)
//Install it.

but in C++/CLI that does not work:

if(myDelegate== nullptr)
//Install it.

gives:

Error C3918:usage requires 'member' to be a data member

But myDelegate has operator == overloaded. I don't understand why it fails.
If I try some like this:

myDelegate->GetInvocationL ist()->Length==0

I get same error.

And other variations.
--
Visita mi blog: http://rfog.blogsome.com
Libros, ciencia ficción y programación
=============== =============== ==========
La amistad es más difícil y más rara que el amor. Por eso, hay que salvarla
como sea.
-- Alberto Moravia. (1907-1990) Escritor italiano.
Oct 13 '06 #1
1 5697

"RFOG" <ze************ @QUITAME.gmail. comwrote in message
news:uz******** ******@TK2MSFTN GP02.phx.gbl...
In C# is very easy:

if(myDelegate== null)
//Install it.

but in C++/CLI that does not work:

if(myDelegate== nullptr)
//Install it.

gives:

Error C3918:usage requires 'member' to be a data member
Use a custom event, like this:

private:

//! \brief MulticastDelega te chain of event handlers for the \ref Closed
event.

System::EventHa ndler^ CloseHandlers;

public:

virtual event System::EventHa ndler^ Closed

{

void add( System::EventHa ndler^ handler )

{

CloseHandlers += handler;

}

void remove( System::EventHa ndler^ handler )

{

CloseHandlers += handler;

}

}

>
But myDelegate has operator == overloaded. I don't understand why it
fails.
If I try some like this:

myDelegate->GetInvocationL ist()->Length==0

I get same error.

And other variations.
--
Visita mi blog: http://rfog.blogsome.com
Libros, ciencia ficción y programación
=============== =============== ==========
La amistad es más difícil y más rara que el amor. Por eso, hay que
salvarla como sea.
-- Alberto Moravia. (1907-1990) Escritor italiano.


Nov 7 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
2312
by: Tim Haughton | last post by:
I've just released an article on using Test Driven Development with C# and Windows Forms. GUI's are often difficult to test, so I thought it might be of interest. The article along with the example source code can be downloaded here: http://www.blogitek.com/timhaughton/archives/files/User%20Interrogator%20And%20TDD.zip The article text is below. Not sure what it will do to the formatting when
1
1690
by: Michael A. Covington | last post by:
Is there a simple way to empty out the Paint delegate (which is a list of method calls) before adding something to it? I'm envision a large, casually designed, experimental program in which various menu choices will each put a different routine into OnPaint, and each of them would want to clear out the previously added ones first, without necessarily knowing what they are. I can't use assignment (=) with this.Paint, but I can use +=...
3
2617
by: Minh Khoa | last post by:
Please give me more information about delegate and its usage? Why do i use it and when?
7
1778
by: Ant | last post by:
Hello, Very simple question but one I need clarified. Which part of the statement below is considered the 'delegate'? Is it the 'new System.EventHandler' or the btnAccept_Click? or is it the piece of code which doesn't appear here, but abstracts the btnAccept_Click method?
2
3431
by: =?Utf-8?B?QXJtaW4gR2FsbGlrZXI=?= | last post by:
Hi I've got an unexpected error in a unit test. I want to test a activity from Windows Workflow Foundation (WF). First, I executed the test outside of the activity just in the test-init method. In this case all works fine: public void TestInitialize() {
7
2725
by: Stefan Hoffmann | last post by:
hi @all, is there something like an anonymous delegate? This is the original code: -- private delegate void DelegateSetFormCaption(string text); private void SetFormCaption(string text) {
0
2941
by: CMELLO | last post by:
I have am dynamically loading a web user control based on the click of a tab strip I load the default control for the first tab in the page load event after checking page is not postback. After that the controls are loaded/unloaded based on the SelectionChanged event for the tab strip and again in Page load because with a dynamic load viewstate has to be reloaded. I have a datalist in the user control and I am trying to create the...
0
1915
by: =?Utf-8?B?Y2luZHk=?= | last post by:
I have am dynamically loading a web user control based on the click of a tab strip I load the default control for the first tab in the page load event after checking page is not postback. After that the controls are loaded/unloaded based on the SelectionChanged event for the tab strip and again in Page load because with a dynamic load viewstate has to be reloaded. I have a datalist in the user control and I am trying to create the...
2
10043
by: hcaptech | last post by:
This is my Test.can you help me ? 1.Which of the following statement about C# varialble is incorrect ? A.A variable is a computer memory location identified by a unique name B.A variable's name is used to access and read the value stored in it C.A variable is allocated or deallocated in memory during runtime D.A variable can be initialized at the time of its creation or later 2. The.……types feature facilitates the definition of classes...
0
9563
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9383
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10139
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
9933
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7364
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6642
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5268
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5405
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3916
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.