System.Net.DnsEndPoint.Equals C# (CSharp) Method

Equals() public method

public Equals ( object comparand ) : bool
comparand object
return bool
        public override bool Equals(object comparand)
        {
            DnsEndPoint dnsComparand = comparand as DnsEndPoint;

            if (dnsComparand == null)
            {
                return false;
            }

            return (_family == dnsComparand._family &&
                    _port == dnsComparand._port &&
                    _host == dnsComparand._host);
        }

Usage Example

Esempio n. 1
0
		public void Constructor_StringInt ()
		{
			Assert.Throws<ArgumentNullException> (delegate {
				new DnsEndPoint (null, 0);
			}, "ctor(null,0)");
			Assert.Throws<ArgumentException> (delegate {
				new DnsEndPoint (String.Empty, 0);
			}, "ctor(Empty,0)");
			Assert.Throws<ArgumentOutOfRangeException> (delegate {
				new DnsEndPoint ("localhost", -1);
			}, "ctor(localhost,-1)");
			Assert.Throws<ArgumentOutOfRangeException> (delegate {
				new DnsEndPoint ("localhost", (0xffff + 1));
			}, "ctor(localhost,(0xffff + 1))");

			DnsEndPoint dep = new DnsEndPoint ("localhost", 65535);
			Assert.AreEqual (AddressFamily.Unspecified, dep.AddressFamily, "AddressFamily");
			Assert.AreEqual ("localhost", dep.Host, "Host");
			Assert.AreEqual (65535, dep.Port, "Port");
			Assert.IsFalse (dep.Equals (null), "Equals(null)");
			Assert.IsTrue (dep.Equals (dep), "Equals(self)");
			Assert.AreEqual ("Unspecified/localhost:65535", dep.ToString ());
		}
All Usage Examples Of System.Net.DnsEndPoint::Equals