.NET Dictionaries have same keys and values, but aren't “equal”

前端 未结 6 1215
旧时难觅i
旧时难觅i 2021-01-17 08:48

This test fails:

using Microsoft.VisualStudio.TestTools.UnitTesting;        

[TestMethod()]
        public void dictEqualTest() {
            IDictionary<         


        
6条回答
  •  礼貌的吻别
    2021-01-17 09:04

    The problem is with this line of code:

    Assert.AreEqual(dict, dictClone)
    

    You are comparing object references, which aren't equal.

提交回复
热议问题