第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問(wèn)題,去搜搜看,總會(huì)有你想問(wèn)的

有沒(méi)有什么好的方式可以寫(xiě)引用參數(shù)的委托?

有沒(méi)有什么好的方式可以寫(xiě)引用參數(shù)的委托?

C#
尚方寶劍之說(shuō) 2023-02-17 17:13:58
如果Action托管的函數(shù)參數(shù)有引用參數(shù), 請(qǐng)問(wèn)怎么寫(xiě)?麻煩熟悉的朋友指點(diǎn)下謝謝void testinter(ref int);Aciont<ref int> a = testinter;//這句是會(huì)報(bào)錯(cuò)的請(qǐng)問(wèn)怎么寫(xiě)好點(diǎn)是不是Action不能寫(xiě)引用參數(shù), 不想自己定義 delegate 類(lèi)型
查看完整描述

1 回答

?
慕田峪4524236

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);

}
}
}
}


查看完整回答
反對(duì) 回復(fù) 2023-02-20
  • 1 回答
  • 0 關(guān)注
  • 84 瀏覽

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢(xún)優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)