In What’s in a name? (C#’s hidden support for structural typing) we explored a few of the areas in which C# currently supports structural typing. I would like to propose two new additions to C#’s structural typing abilities: implicit interface inheritance and richer generic constraints. Implicit interface inheritance I propose that class or struct ought [...]
Tag Archives: type-system
Two structural additions to C#
28-Apr-10C# is well known for its nominative type system. This means that C# identifies types and their relationships based on their names. That is why C# does not allow you to create two types with the same name, even if they have a different public interface – the C# compiler only cares about the name [...]
In part 1 of this series I explained the difference between reference equality and value equality. In this article I am going to demonstrate how to compare two reference types using value equality semantics. Override Object.Equals Every time you use the binary equality operator (==) or the Equals method on a reference type you are [...]
All types are not compared equally
29-Oct-09Here is a bit of a quiz: What does this program print? using System; using System.Collections.Generic; class Person { public String Name { get; set; } } class Example { static void Main() { var people = new List<Person> { new Person { Name = “George Washington” } }; Console.WriteLine( people.Contains( new Person { Name [...]