tags:

views:

170

answers:

7

Possible Duplicate:
C# memcpy equivalent

Kindly tell me any equivalent function of memcpy in c#?

+1  A: 

There is none. C# protects the actual memory behind several layers of abstraction. For some purposes, the IClonable interface may be of some help though.

Matthew Scharley
+1  A: 

Not an exact equivalent, but does Array::Copy do what you need to do?

In silico
+1  A: 

For copying (byte) arrays, you can use the Array.Copy() method, but that's probably not what you want:

byte[] array1 = new byte[10] { 1,2,3,4,5,6,7,8,9,10 };
byte[] array2 = new byte[10];

Array.Copy(array1,array2,10);
Philippe Leybaert
Or, alternatively, `Buffer.BlockCopy`. http://msdn.microsoft.com/en-us/library/system.buffer.blockcopy.aspx
LukeH
+1  A: 

You can use unsafe and pointers. But your particular case would say a bit more about what direction you should head.

Mikael Svenson
+1  A: 

Buffer.BlockCopy is close, but limited to arrays. I agree it depends what you're trying to do.

Matthew Flaschen
A: 

there's an example on the MSDN page, that uses byte[] to copy memory directly. Maybe that's what you're looking for...

king_nak
+2  A: 

As already said it depends what you are trying to do... So you can consider one of these... check the links:

There may be other possible options based on your needs...

Incognito