// Collection of code snippets by Arne Vajhøj // (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) using System; using System.Runtime.InteropServices; namespace MemoryFun { public class Program { public static void Main(string[] args) { int[] ia = { 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111 }; Span si = ia; Span sb = MemoryMarshal.Cast(si); Span sb2 = sb.Slice(2, 16); for(int i = 0; i < 16; i++) { sb2[i] = 0; } for(int i = 0; i < 5; i++) { Console.Write(" {0,8:X8}", ia[i]); } Console.WriteLine(); } } }