所以,我有兩種方法:我有兩個功能只有一些條件不同。它可以統一嗎?
public static string Figure2D()
{
dynamic shapeValue;
do
{
shapeValue = Presentation.Present();
}
while (shapeValue.Is3D);
return shapeValue.ToString("R");
}
public static string Figure3D()
{
dynamic shapeValue;
do
{
shapeValue = Presentation.Present();
}
while (!shapeValue.Is3D);
return shapeValue.ToString("R");
}
它們之間唯一的區別是while條件。我怎樣才能將這兩個功能合併成一個功能?傳遞參數值可能需要&,但我確實希望保持簡短。有任何想法嗎?
如何@stuartd出現了一個'!'在一個 – degant
@stuartd一個被否定,另一種是不。 – Bytewave
小文本再次獲勝,對不起 – stuartd