1

Is there something like c++ pointer in c# because I want change value of variable declared in another method. My method must return bool value but also I have to change value of string variable.

In C++ there was a pointer and I don't know how to do that in C#. I read about pointers in C# but there was something about "unsafe".

I want to avoid using global variables.

Brath
  • 53
  • 1
  • 5
  • 2
    there is but I think it is best to first describe a bit more what your methods are doing and classes - maybe you do not need it – Gilad Green Nov 02 '17 at 06:41
  • If you want to change value in method, consider looking for [`ref`](https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/ref) and [`out`](https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/out-parameter-modifier) keywords. – Ahmad Khan Nov 02 '17 at 07:21
  • Check this out : How to: Obtain the Address of a Variable (C# Programming Guide) - https://learn.microsoft.com/en-us/dotnet/csharp/programming-guide/unsafe-code-pointers/how-to-obtain-the-address-of-a-variable – Jake Nov 03 '17 at 07:46
  • Thanks, ref and out is what I need. – Brath Nov 03 '17 at 08:47

0 Answers0