using System;
 
 namespace UnsafeTest
{
    unsafe struct link
    {
        public int x;
        public link* next;
    }
    class Program
    {
        static unsafe void Main(string[] args)
        {
            int val;
            link* head = stackalloc link[sizeof(link)];
            
            link*q =head;
            for(int i=0;i<=10;i++)
            {
                val = i+100;
                link* temp = stackalloc link[sizeof(link)];
                q->x = val;
                q->next = temp;
                q = temp;
            }
             
            link* t = head;
            while(t->next!=null)
            {
 
                Console.WriteLine(t->x );
                t = t->next;
            }
        }
    }
}

 

相关文章:

  • 2021-11-17
  • 2021-06-21
  • 2022-12-23
  • 2021-11-22
猜你喜欢
  • 2021-04-10
  • 2022-12-23
  • 2021-07-06
  • 2022-12-23
  • 2022-02-23
相关资源
相似解决方案