class Person {
public string
FirstName { get; set; }
public string LastName
{ get; set; }
}
using System;
namespace pc.IEquatableExample
{
class Person {
public string
FirstName { get; set; }
public string LastName
{ get; set; }
}
class Program
{
static void Main(string[] args)
{
var p1 = new Person { FirstName = "Pawel", LastName = "Ciucias" };
var p2 = new Person { FirstName = "Pawel", LastName = "Ciucias" };
Console.WriteLine($"p1 is the same as p2:" + p1.Equals(p2));
}
}
}
static void Main(string[] args)
{
var p1 = new Person { FirstName = "Pawel", LastName = "Ciucias" };
var p2 = p1;
Console.WriteLine($"p1 is the same as p2:" + p1.Equals(p1));
}
using System;
namespace pc.IEquatableExample
{
class Person : IEquatable<Person>
{
public string
FirstName { get; set; }
public string LastName
{ get; set; }
public bool Equals(Person other)
{
return FirstName == other.FirstName &&
LastName == other.LastName;
}
}
class Program
{
static void Main(string[] args)
{
var p1 = new Person { FirstName = "Pawel", LastName = "Ciucias" };
var p2 = new Person { FirstName = "Pawel", LastName = "Ciucias" };
Console.WriteLine($"p1 is the same as p2:" + p1.Equals(p1));
}
}
}