-4

I am new to this forum and C# programming.Working on this project where I have to return time interval as a double after if control statement finished. Code snippet is below. Please tell me what I am doing wrong. It's not returning d;

public double GetInterval()
{
    double d;
    DateTime now = new DateTime();

    if (cb5Min.Checked)
    {
        d = ((60 - now.Second) * 1000 - now.Millisecond);            
    }
    else if (cb15Min.Checked)
    {
        d= ((900 - now.Second) * 1000 - now.Millisecond);
    }

    return d;
}
4

2 に答える 2

0

ここTimeSpanで構造と例を見てください

于 2013-02-12T10:29:28.533 に答える
0

すべてのパスが更新されるわけではありません。cb5Min.checked が false で cb15Min.checked が false の場合、コードは d の unitinitialized 値を返します。

于 2013-02-12T10:30:03.920 に答える