473,395 Members | 1,458 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

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 1885
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.com> wrote in message
news:ea**************@TK2MSFTNGP11.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.GetFunctionPointerForDelegate(myDelegate).

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
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...
5
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
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
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...
1
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....
6
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...
2
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 =...
5
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...
6
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,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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...
0
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,...
0
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...
0
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...
0
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...

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.