Subtext.Framework.BlogInfo.Equals C# (CSharp) Method

Equals() public method

Returns true if the two instances are equal
public Equals ( object obj ) : bool
obj object Obj.
return bool
        public override bool Equals(object obj)
        {
            if (obj == null || GetType() != obj.GetType())
                return false;

            return ((BlogInfo)obj).Id == this.Id;
        }

Usage Example

Example #1
0
        public void CanTestForEquality()
        {
            BlogInfo blog = new BlogInfo();
            blog.Id = 12;
            Assert.IsFalse(blog.Equals(null), "Blog should not equal null");
            Assert.IsFalse(blog.Equals("Something Not A Blog"), "Blog should not equal a string");

            BlogInfo blog2 = new BlogInfo();
            blog2.Id = 12;
            Assert.IsTrue(blog.Equals(blog2));
        }