why to use ref keyword for passing string parameter in function calling

前端 未结 2 757
渐次进展
渐次进展 2021-01-27 17:59

String is a reference type , so why we have to attach ref keyword ahead of string variable when we are passing in a function call for getting change in a main function For ex:

2条回答
  •  爱一瞬间的悲伤
    2021-01-27 18:43

    Update passing by reference as per comments below.

    When you add the ref keyword in, you are passing by value passing a reference to the underlying value and can therefore, change the value of the data. A reference variable is like a pointer, not the value itself.

    Read the MSDN article.

提交回复
热议问题