Change value inside an (void) extension method

前端 未结 6 1022
心在旅途
心在旅途 2021-02-12 23:28

So I have this mock extension method which change a value to another value:

public static void ChangeValue(this int value, int valueToChange)
{
    value = value         


        
6条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2021-02-12 23:57

    You can't do that without using either a return value, or a ref parameter. The latter doesn't work alongside this (extension methods), so your best bet is a return value (rather than void).

提交回复
热议问题