2
對不起,我的無知,但我一直試圖很長一段時間沒有一個合理的解釋: 爲什麼+
運算符不會拋出任何異常時,任何參數是null
; 例如:爲什麼+運算符在任何空參數時不會拋出任何異常?
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication4
{
class Program
{
static void Main(string[] args) {
string str = null;
Console.WriteLine(str + "test");
Console.ReadKey();
}
}
}
因爲'string.Concat(...)'允許'null'參數 – leppie