[問題] 請教 null 的用法
請教各位高手,下面的寫法是甚麼意思?
謝謝!
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
討論串 (同標題文章)
以下文章回應了本文 (最舊先):
完整討論串 (本文為第 1 之 3 篇):
C_Sharp 近期熱門文章
PTT數位生活區 即時熱門文章