A question regarding unsafe
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2

Thread: A question regarding unsafe

  1. #1
    Join Date
    Jul 2005
    Posts
    928

    A question regarding unsafe

    Here is the code,
    Code:
    namespace ConsoleApplication1
    {
        class Program
        {
            static void Main(string[] args)
            {
                unsafe
                {
                    int* p = new int(4);
    
                    Console.WriteLine(*p);
    
                    delete p;
                }
            }
        }
    }
    There is compiler errors. What is wrong with the code? Thanks.

  2. #2
    Join Date
    Jan 2012
    Location
    India
    Posts
    138

    Cool Re: A question regarding unsafe

    This is c/c++ code you are trying to compile on C# ..

    The array is declared in totally different way .. syntax is int [] p ....

    Also there is no concept of "delete" .. it is taken care by garbage collector.

    Pl read article on arrays either on MSDN or on this site itself

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center