Is there pointer in C# like C++? Is it safe?

后端 未结 5 1538
抹茶落季
抹茶落季 2020-12-08 18:20

I\'m writing an application that work with a tree data structure. I\'ve written it with C++, now i want to write it by C#. I use pointers for implementing the tree data stru

5条回答
  •  误落风尘
    2020-12-08 19:24

    Is there pointer in C# too?

    Yes, declared using the syntax int* varName;.

    Is using of that safe?

    No pointers are not safe.

    There are safe ways to construct a data structure without pointers. If the nodes are classes, then they'll automatically be reference types so you don't need any pointers. Otherwise, you can box them into a reference.

提交回复
热议问题