none
Get from array without ref in C# RRS feed

  • Question

  • Hello,

    Suppose we cannot use ref here. How can do this without ref keyword?

    Thanks

    Saturday, October 12, 2019 1:00 AM

Answers

  • Maybe like this:

    var setter = Change( str, POS );

    setter( "NEW" );

    . . .

    static Action<string> Change( string[] str, int POS )

    {

       return s => str[POS] = s;

    }

    • Edited by Viorel_MVP Saturday, October 12, 2019 8:11 AM
    • Marked as answer by Arash_89 Saturday, October 12, 2019 11:08 AM
    Saturday, October 12, 2019 8:10 AM