473,728 Members | 1,909 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

how to convert a delegate to int

DR
I created a new delegate object and I want to pass it to a function which
takes int.
How to convert to int?
Feb 20 '06 #1
4 1899
I created a new delegate object and I want to pass it to a function which
takes int.


Why is the parameter type an int? Is this a call to a native DLL where
the int represents a function pointer?
Mattias

--
Mattias Sjögren [C# MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
Feb 20 '06 #2

"DR" <dr****@yahoo.c om> wrote in message
news:ea******** ******@TK2MSFTN GP11.phx.gbl...
|I created a new delegate object and I want to pass it to a function which
| takes int.
| How to convert to int?
|
|

You should not convert it to an int, an int is not platform independent,
declare your function to take a delegate, or, when using V2 of the framework
an IntPtr returned from the call to
Marshal.GetFunc tionPointerForD elegate(myDeleg ate).

Willy.

Feb 20 '06 #3
Hello, DR!

D> I created a new delegate object and I want to pass it to a function
D> which takes int.
D> How to convert to int?

For what purpose you want do this?
If you mean passing delegates as callback to the unmanaged code, then
( http://msdn.microsoft.com/library/en...backSample.asp )

--
Regards, Vadym Stetsyak
www: http://vadmyst.blogspot.com
Feb 20 '06 #4
DR
I have a COM object which takes a function pointer as int (or long).
Hello, DR!

D> I created a new delegate object and I want to pass it to a function
D> which takes int.
D> How to convert to int?

For what purpose you want do this?
If you mean passing delegates as callback to the unmanaged code, then
(
http://msdn.microsoft.com/library/en...backSample.asp )

--
Regards, Vadym Stetsyak
www: http://vadmyst.blogspot.com

Feb 20 '06 #5

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

Similar topics

6
14378
by: juli | last post by:
I declared: public delegate void PaintEventHandler(object objSender,PaintEventArgs pea); and this.Paint+=new PaintEventHandler(MyPaintHandler); and the: static void MyPaintHandler(object objSender,PaintEventArgs pea) { }
5
1159
by: Supra | last post by:
how to convert fromVC# to VB.net.... in vc# : private delegate void NewFormDelegate(Form f); public void NewMdiForm(Form f) { this.Invoke(new NewFormDelegate(NewForm),new object{f}); }
5
75260
by: Andrew Robinson | last post by:
Any easy answer what is wrong here? private List<string> BodyWords = new List<string>(); string word = "Andrew"; the following causes a compilation error:
5
3789
by: Learner | last post by:
Hello, Here is the code snippet I got strucked at. I am unable to convert the below line of code to its equavalent vb.net code. could some one please help me with this? static public List<RoleData> GetRoles() { return GetRoles(null, false); }
1
1740
by: Robert Dufour | last post by:
I am trying to sort the membership list of the membership provider for ASP.NET the code has retrieved the list and now we need to sort it by a parameter if it was passed. So in C# the code is. Comparison<MembershipUserWrappercomparer = null; switch (sortDataBase) {
6
6869
by: Sergey Poberezovskiy | last post by:
I have the following code in C# that I have trouble converting to VB(2.0): private delegate void openDialog(); private void openWindowsDialog(openDialog open) { Thread thread = new Thread(new ThreadStart(open)); thread.SetApartmentState(ApartmentState.STA); thread.Start(); }
2
1274
by: Mika M | last post by:
This should be easy, but I don't figure it out... private void setInfoText(string text) { if (this.statusStrip1.InvokeRequired) { this.Invoke((MethodInvoker)delegate() { this.pnlInfo.Text = text; });
5
5707
by: Satish | last post by:
When i compile this function I get the error Cannot convert lambda expression of type System.delegate because it is not a delegate type. private void SetStatus(string status) { if (this.InvokeRequired) { this.Invoke( status =SetStatus(status)); } else
6
2826
by: =?ISO-8859-1?Q?Norbert_P=FCrringer?= | last post by:
Hello, Imagine, that I've got a string variable containing a value of each possible value type (string, int32, double, ...). Now I want to convert the string to an object of the right type, where the correct type is given by a Type variable. So given is: string strValue; Type typeValue;
0
8903
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
8758
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
9277
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9198
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,...
0
9130
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8129
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
4524
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
4792
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2663
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.