Beispiel #1
0
    public static unsafe void Main()
    {
        int     id      = 101;
        decimal balance = 50.55m;
        Account acc     = new Account(id, balance);

        ShowAccount(&acc);
        Account[] array = new Account[5];
        //Console.WriteLine("size of Account[] = {0}", sizeof(Account[]));
        ShowArray(array);
        fixed(Account *pStart = array)
        {
            Account *pAcc = pStart;

            for (int i = 0; i < array.Length; i++)
            {
                *pAcc++ = acc;
            }
        }

        ShowArray(array);
    }
Beispiel #2
0
 private static unsafe void ShowAccount(Account *pAcc)
 {
     Console.WriteLine("id = {0}, balance = {1:C}", pAcc->id, pAcc->balance);
 }