Range.cs source code in C# .NET

Source code for the .NET framework in C#

                        

Code:

/ 4.0 / 4.0 / untmp / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / Data / System / Data / Range.cs / 1305376 / Range.cs

                            //------------------------------------------------------------------------------ 
// 
//     Copyright (c) Microsoft Corporation.  All rights reserved.
// 
// [....] 
// [....]
// [....] 
//----------------------------------------------------------------------------- 

namespace System.Data { 
    using System;

    internal struct Range {
 
        private int min;
        private int max; 
        private bool isNotNull; // zero bit pattern represents null 

        public Range(int min, int max) { 
            if (min > max) {
                throw ExceptionBuilder.RangeArgument(min, max);
            }
            this.min = min; 
            this.max = max;
            isNotNull = true; 
        } 

        public int Count { 
            get {
                if (IsNull)
                    return 0;
                return max - min + 1; 
            }
        } 
 
        public bool IsNull {
            get { 
                return !isNotNull;
            }
        }
 
        public int Max {
            get { 
                CheckNull(); 
                return max;
            } 
        }

        public int Min {
            get { 
                CheckNull();
                return min; 
            } 
        }
 
        internal void CheckNull() {
            if (this.IsNull) {
                throw ExceptionBuilder.NullRange();
            } 
        }
    } 
} 

// File provided for Reference Use Only by Microsoft Corporation (c) 2007.


                        

Link Menu

Network programming in C#, Network Programming in VB.NET, Network Programming in .NET
This book is available now!
Buy at Amazon US or
Buy at Amazon UK