C# dynamic

zyip發表於2014-01-27

 

 

        [TestMethod]
        public void DynamicTest()
        {
            dynamic Customer = new ExpandoObject();
            Customer.Name = "Lucy";
            Customer.Age = 20;
            Customer.Female = true;

            var obj = new { name="zy", age="20" };

            var t =obj.GetType().ToString();
            var t2 = Customer.GetType().ToString();

            Assert.AreEqual(Customer.Name, "Lucy"); 
            
        }

 

 

  On your solution explorer window, right click to References, select Add Reference, go to .NET tab, find and add Microsoft.CSharp.

 

相關文章