1 回答

TA貢獻(xiàn)1875條經(jīng)驗(yàn) 獲得超5個(gè)贊
只能這么玩,現(xiàn)有的不支持ref
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication5
{
class Program
{
static void Main(string[] args)
{
var w = new Work
{
OnNotify = Run
};
w.Do();
Console.Read();
}
private static void Run(ref int i)
{
i += 1;
Console.Write(i);
}
}
public delegate void RefAction<T1>(ref T1 arg1);
public class Work
{
public RefAction<int> OnNotify;
public void Do()
{
var j = 0;
for (var i = 0; i < 10; i++)
{
j += 1;
if (OnNotify != null)
{
OnNotify(ref j);
}
}
}
}
}
- 1 回答
- 0 關(guān)注
- 84 瀏覽
添加回答
舉報(bào)