Are ref and out in C# the same a pointers in C++?

后端 未结 7 454
挽巷
挽巷 2021-01-05 04:00

I just made a Swap routine in C# like this:

static void Swap(ref int x, ref int y)
{
    int temp = x;
    x = y;
    y = temp;
}

It does t

7条回答
  •  北海茫月
    2021-01-05 04:22

    Actually, I'd compare them to C++ references rather than pointers. Pointers, in C++ and C, are a more general concept, and references will do what you want.

    All of these are undoubtedly pointers under the covers, of course.

提交回复
热议问题