You are currently viewing the BOOK: Beginning ASP.NET 4 : in C# and VB section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Both would work, and both would be considered "magic numbers".... ;-)
The reason I chose -1 is that 0 is the default value for an integer that hasn't been initialized explicitly. By setting it to -1, I know I set it to -1 or undefined, and not the .NET run-time.
A better alternative would be to use a nullable int; then you can check HasValue to determine if the variable has been assigned a value not.