[TestFixture]
    public class StructFixtrue
    {
        [Test]
        public void TestStruct()
        {
            DateTime a = DateTime.Now;
            DateTime b = a;
            Assert.AreEqual(a, b, "Two structs' value are equal.");
            Assert.AreNotSame(a, b, "Two structs' instance are not same.");

            Object c = new object();
            Object d = c;
            Assert.AreEqual(c, d, "Two objects' value are equal.");
            Assert.AreSame(c, d, "Two objects' instance are same.");
        }
    }

 

结论:Struct是存在栈中。

注:值类型保存在栈中,故等值不等址;引用类型保存在堆中,故等值等址。

posted on 2007-07-11 21:20  Sam Zhang  阅读(480)  评论(0编辑  收藏  举报