[問題] 請教 null 的用法

看板C_Sharp (C#)作者 (小黑)時間11年前 (2014/01/08 01:16), 編輯推噓0(000)
留言0則, 0人參與, 最新討論串1/3 (看更多)
請教各位高手,下面的寫法是甚麼意思? 謝謝! if (Math.Abs(t - 0.3) < dt / 2) { write("..\\(2D)u" + filename + ".plt", u); write("..\\(2D)uexact_" + filename + ".plt", null); } ////// public static void write(string fname, fun ux) { FileStream fs = new FileStream(fname, FileMode.Create); StreamWriter sw = new StreamWriter(fs, Encoding.Default); sw.WriteLine("VARIABLES=x, y, u1"); sw.WriteLine("ZONE T=\"dx={0}, dy={1}\", I={2}, J={3}, F=POINT", dx, dy, Ni/2, Nj); for (double y = 0; y <= MaxY; y += dy) for (double x = 0; x <= MaxX; x += dx) { double uk=(ux==null)? (exact(t,x,y)): ux.f1(0, x, y, 0, 0, 0); sw.WriteLine("{0},{1},{2}", x, y, uk); } sw.Close(); } 請教: double uk=(ux==null)? (exact(t,x,y)): ux.f1(0, x, y, 0, 0, 0); 是甚麼樣的邏輯? 我讀出來的檔案 write("..\\(2D)uexact_" + filename + ".plt", null); 只有時間t有值,而x,y皆為零,是否與 null 有關? -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 140.116.155.138
文章代碼(AID): #1Ip3PVCP (C_Sharp)
文章代碼(AID): #1Ip3PVCP (C_Sharp)