今天我們談論下佛法。
佛曰:空即是色, 色即是空。
用我們的專業屬於就是:空可以賦給任何類, 任何類都可以賦值為空白。
萬物皆對象, 空, 也不例外。
但是佛法一項是繞到你頭疼的一個東西。 他也認為,
對的也是錯的, 錯的也是對的。 諸如此類一個老和尚能把你說得頭暈轉向的東西。
所以空, 又什麼都不是。
這個如何理解呢?
C#代碼,
我們舉例如下:
static void Main(string[] args)
{
Console.WriteLine(null is Form);
Console.WriteLine(null is Button);
Console.WriteLine(null is TrackBar);
Console.WriteLine(null is DomainUpDown);
Console.WriteLine(null is Graphics);
Console.WriteLine(null is string);
Console.WriteLine(null is Array);
}
程式輸出:
False
False
False
False
False
False
False
請按任意鍵繼續. . .
額, 看起來似乎空什麼都不是額。。
所有的判斷都是false, 說明空不是任意
對象
這裡我僅僅舉例了一些從參考型別繼承的。 實值型別的就更不用說了。
但是另一面確是這個樣子的:
static void Main(string[] args)
{
TestMethod1(null);
TestMethod2(null);
TestMethod3(null);
TestMethod4(null);
TestMethod5(null);
TestMethod6(null);
TestMethod7(null);
}
public static void TestMethod1(Form value)
{ }
public static void TestMethod2(Button value)
{ }
public static void TestMethod3(TrackBar value)
{ }
public static void TestMethod4(DomainUpDown value)
{ }
public static void TestMethod5(Graphics value)
{ }
public static void TestMethod6(string value)
{ }
public static void TestMethod7(Array value)
{ }
嘗試編譯這段代碼, 運行良好。。
也就是僅僅從類型判斷的話, 空是所有對象。
這就困惑了吧, 到底空是不是色?null是不是對象?
這也就是程式設計大師一般都反對教條類學生“追究最根本原理”的原因之一。
我相信到這裡很多人已經心領神會了。
對應下開頭。
本講結束。