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

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

像這樣只是類型不同的方法可以優(yōu)化嗎?

像這樣只是類型不同的方法可以優(yōu)化嗎?

C#
白衣染霜花 2018-12-06 19:07:37
public static int[] DataDifference(int[] more, int[] few) { //差異Id var sbuNoItapSessionId = new int[more.Length - few.Length]; var indexi = 0; for (int i = 0; i < more.Length; i++) { var isHave = false; for (int j = 0; j < few.Length; j++) { if (more[i].Equals(few[j])) { isHave = true; break; } } if (!isHave) { sbuNoItapSessionId[indexi] = more[i]; indexi++; } } return sbuNoItapSessionId; } public static string[] DataDifference(string[] more, string[] few) { //差異Id var sbuNoItapSessionId = new string[more.Length - few.Length]; var indexi = 0; for (int i = 0; i < more.Length; i++) { var isHave = false; for (int j = 0; j < few.Length; j++) { if (more[i].Equals(few[j])) { isHave = true; break; } } if (!isHave) { sbuNoItapSessionId[indexi] = more[i]; indexi++; } } return sbuNoItapSessionId; } public static ResultMessage StitchingAndReturnsAnArray(int[] datas) { var noIds = new StringBuilder(); var result = new ResultMessage(); if (datas != null && datas.Count() != 0) { for (int i = 0; i < datas.Length; i++) { if (i > 0) { noIds.Append(","); } noIds.Append(datas[i]); } result.Success = "false"; result.Message = noIds.ToString(); } else { result.Success = "true"; } return result; } public static ResultMessage StitchingAndReturnsAnArray2(string[] datas) { var noIds = new StringBuilder(); var result = new ResultMessage(); if (datas != null && datas.Count() != 0) { for (int i = 0; i < datas.Length; i++) { if (i > 0) { noIds.Append(","); } noIds.Append(datas[i]); } result.Success = "false"; result.Message = noIds.ToString(); } else { result.Success = "true"; } return result; } ? 可以看到代碼中代碼基本全部都重復(fù),可是像這樣只是類型不同的方法,又該怎么去優(yōu)化呢? 跪求大神指教
查看完整描述

1 回答

?
Cats萌萌

TA貢獻(xiàn)1805條經(jīng)驗(yàn) 獲得超9個(gè)贊

泛型啊``

查看完整回答
反對(duì) 回復(fù) 2018-12-24
  • 1 回答
  • 0 關(guān)注
  • 565 瀏覽

添加回答

舉報(bào)

0/150
提交
取消
微信客服

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

幫助反饋 APP下載

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

公眾號(hào)

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