c# - How to use KeyValuePair in a Dictionary

How to use KeyValuePair
HowToUseKeyValuePair.aspx

<%@ Page Language="C#" AutoEventWireup="true" %>
<%@ Import Namespace="System.Collections.Generic" %>

<!DOCTYPE html>
<script runat="server">
    protected void Button1_Click(object sender, System.EventArgs e)
    {
        Dictionary<string, string> colors = new Dictionary<string, string>();
        colors.Add("Crimson", "#DC143C");
        colors.Add("DarkGreen", "#006400");
        colors.Add("DarkMagenta", "#8B008B");
        colors.Add("DarkSlateBlue", "#483D8B");
        colors.Add("DeepPink", "#FF1493");
        
        Label1.Text = "Dictionary Keys and Values.....<br /><br />";
        foreach(KeyValuePair<string,string> pair in colors)
        {
            Label1.Text += "<font color="+pair.Key+">"+pair.Key +"</font> "+ pair.Value + "<br />";
        }
    }
</script>

<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title>How to use KeyValuePair</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <h2 style="color:Navy; font-style:italic;">
            System.Collections.Generic
            <br /> How to use KeyValuePair
        </h2>
        <hr width="350" align="left" color="DodgerBlue" />
        <br />
        <asp:Label
             ID="Label1"
             runat="server"
             ForeColor="DodgerBlue"
             Font-Names="Courier New"
             Font-Size="X-Large"
             >
        </asp:Label>
        <br />
        <asp:Button 
            ID="Button1"
            runat="server"
            OnClick="Button1_Click"
            Text="Test KeyValuePair"
            Height="45"
            Font-Bold="true"
            ForeColor="Navy"
            />
    </div>
    </form>
</body>
</html>
More c# examples