Leah Hurst
Leah Hurst

Reputation: 400

Any reason to compute an INT for a constant?

In another part of the pasketti code I've inherited, I came across this:

public const int SqlCommandTimeout = 60 * 10;

Is there any reason why this should be a calculated value that is then placed into a constant?

My C# training has all been on-the-job with a book or two for backup, so for all I know there could have been a valid reason for this.

Upvotes: 1

Views: 49

Answers (2)

TheEvilPenguin
TheEvilPenguin

Reputation: 5672

Only to show the reasoning behind the constant value. It seems like a long time, but if SqlCommandTimeout is in seconds, this is a good way to show it's 10 minutes instead of trying to figure out how many minutes there are in 600 seconds.

Upvotes: 2

McGarnagle
McGarnagle

Reputation: 102743

It's just intended to be more readable: 60 * 10 = 10 minutes.

Upvotes: 5

Related Questions