Syntax

C# Define a Record Syntax

In C#, define a record: defines an immutable data type — public record Point(int X, int Y);

Quick Answer

Syntax
public record Point(int X, int Y);
C#Syntax

Define a Record

Code example
public record Point(int X, int Y);

Defines an immutable data type.

Learn More

How to define a record in C#

  1. Open your C# file or editor.
  2. Copy the example, then replace its sample names and values for your code.

C# Define a Record Syntax

Use public record Point(int X, int Y);.

Related Syntax References

Frequently asked questions

What is the C# syntax for define a record?

Use this pattern: public record Point(int X, int Y);

Can I copy this C# code example?

Yes. Use Copy code and adapt the example to your program.

Is this C# syntax different on Mac or Windows?

No. The language syntax is the same across operating systems.

Official source · How we verify