KeyValuePair.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 / clr / src / BCL / System / Collections / Generic / KeyValuePair.cs / 1305376 / KeyValuePair.cs

                            // ==++== 
//
//   Copyright (c) Microsoft Corporation.  All rights reserved.
//
// ==--== 
/*============================================================
** 
** Interface:  KeyValuePair 
**
** [....] 
**
**
** Purpose: Generic key-value pair for dictionary enumerators.
** 
**
===========================================================*/ 
namespace System.Collections.Generic { 

    using System; 
    using System.Text;

    // A KeyValuePair holds a key and a value from a dictionary.
    // It is returned by IDictionaryEnumerator::GetEntry(). 
    [Serializable]
 
    public struct KeyValuePair { 
        private TKey key;
        private TValue value; 

        public KeyValuePair(TKey key, TValue value) {
            this.key = key;
            this.value = value; 
        }
 
        public TKey Key { 
            get { return key; }
        } 

        public TValue Value {
            get { return value; }
        } 

        public override string ToString() { 
            StringBuilder s = new StringBuilder(); 
            s.Append('[');
            if( Key != null) { 
                s.Append(Key.ToString());
            }
            s.Append(", ");
            if( Value != null) { 
               s.Append(Value.ToString());
            } 
            s.Append(']'); 
            return s.ToString();
        } 
    }
}

// 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