userSteve userSteve - 1 year ago 90
C# Question

Is there a difference between these TimeSpan methods?

Are these statements syntactically the same and perform the same ?
Which is preferable?

TimeSpan ts = TimeSpan.FromTicks(100000);


TimeSpan ts = new TimeSpan(100000);

Answer Source

There is no difference between them. The static method initialize new instance using the following constructor.

TimeSpan(Int64) which initializes a new instance of the TimeSpan structure to the specified number of ticks.

public static TimeSpan FromTicks(long value)
    return new TimeSpan(value);
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download