By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
449,220 Members | 1,493 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 449,220 IT Pros & Developers. It's quick & easy.

memcmp()

P: n/a
Hi,

Does anyone know the c#-function of c++'s memcmp()?

Regards,
Mads
Nov 15 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Mads,

There is no such function. memcmp compares two pointers in memory to
see if the referenced bytes are the same. This can't be done in C# because
you can not guarantee that a location in memory will always have the same
contents (because of memory management).

However, if you have two byte arrays, you could easily write a routine
that will cycle through the arrays and compare the bytes.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Mads Jacobsen" <ma***********@pol.dk> wrote in message
news:ux**************@TK2MSFTNGP12.phx.gbl...
Hi,

Does anyone know the c#-function of c++'s memcmp()?

Regards,
Mads

Nov 15 '05 #2

P: n/a
"Mads Jacobsen" <ma***********@pol.dk> wrote in news:uxcxkSJyDHA.1272
@TK2MSFTNGP12.phx.gbl:
Hi,

Does anyone know the c#-function of c++'s memcmp()?

Regards,
Mads

If you have an IntPtr either via fixing the memory via the "fixed" verb
or via the GCHandle.AddrOfPinnedObject() method you can then populate it
via the Marshal.Copy() method.

-
Stephen
Nov 15 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.