C#: Representation of an Anonymous Type: Listing 1

This code is similar to the code created by the compiler for anonymous types. The compiler creates a generic type in order to reuse some code. Also, the compiler generates names that are illegal for handwritten code to avoid collisions with user-defined types.

internal sealed class AnonymousOne
    // Fields
    private readonly int xField;
    private readonly int yField;

    // Methods
    public AnonymousOne(int x, int y)
     this.xField = x;
     this.yField = y;

    public override bool Equals(object value)
     var type = value as AnonymousOne;
     return (((type != null) &&
          type.xField)) &&

   public override int GetHashCode()
        uint num = 0xdd9cb371;
        num = (0xa5555529 * num) +

     return (int)((0xa5555529 * num) + 


   public override string ToString()
      StringBuilder builder = new StringBuilder();
      builder.Append("{ x = ");
      builder.Append(", y = ");
      builder.Append(" }");
      return builder.ToString();

   // Properties
   public int x
      get { return this.xField; }

   public int y
      get { return this.yField; }
comments powered by Disqus


  • Customize Your Own Audio Test Cues in Visual Studio 2019 v16.9 Preview 3

    Yes, developers can be alerted to a failed test with a fart sound.

  • Progress Touts New Third-Party Blazor UI Components

    Third-party dev tool specialist Progress announced an update to its .NET-centric offerings, touting new controls for Blazor, Microsoft's red-hot project for creating web apps with C#.

  • Entity Framework Core 6: What Developers Want

    Microsoft outlined its plan for Entity Framework Core 6, which in November will take its place as the data access component of the landmark .NET 6, a long-term support (LTS) release that will mark Microsoft's transition from the Windows-only .NET Framework to an open source, cross-platform umbrella offering of all things .NET.

  • AWS Open Sources .NET Porting Assistant GUI

    After previously open sourcing components of its Porting Assistant for .NET, Amazon Web Services open sourced the tool's GUI.

Upcoming Events