C# Pointers in a Method's arguments?

后端 未结 5 2050
一个人的身影
一个人的身影 2021-01-11 22:24

I wish to directly modify a variable\'s value outside of a method from inside it.
Pointers are the way, correct?

How?

5条回答
  •  陌清茗
    陌清茗 (楼主)
    2021-01-11 22:31

    Use ref. E.g. Foo(ref int i) will allow Foo to change the value of i via the reference to the caller's value.

提交回复
热议问题