c# for循環獲取dictionary的鍵和值


protected void Button1_Click ( object sender, EventArgs e )
        {
            Dictionary<string, string> DicTest = new Dictionary<string, string>();
            DicTest.Add( "a", "1" );
            DicTest.Add( "b", "2" );
            DicTest.Add( "c", "3" );
            DicTest.Add( "d", "4" );
            DicTest.Add( "e", "5" );
            DicTest.Add( "f", "6" );

            for(int i = 0 ; i < DicTest.Count ; i++)
            {
                Literal1.Text += DicTest.ToList()[i].Key + ":" + DicTest.ToList()[i].Value+ "<br/>";
            }
        }

 

 

前台圖片:

 

后台展示:

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM