docs icon indicating copy to clipboard operation
docs copied to clipboard

Add introduction to creating data types

Open BillWagner opened this issue 4 years ago • 2 comments

Now, with C# 9, there are a number of different ways to create data types in C#:

  • tuples
  • records
  • anonymous types
  • classes
  • structs

Tuples and records, in particular, are great concepts for beginners to learn to build data structures. They both should be introduced before classes.

Open question: Should structs and interfaces be part of this series, or in the fundamentals section?


Document Details

Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.


Associated WorkItem - 400547

BillWagner avatar Feb 05 '21 17:02 BillWagner

I recommend covering interfaces only when classes are introduced, as that's when you're likely to introduce polymorphism. For a .NET dev to be successful with concepts like dependency injection in ASP.NET Core, an understanding of interfaces is essential. I also think it would be unfair to cover C# data types without mention of structs. Sure, they're not as commonly used as classes and interfaces, but it's all about using the right tool for the job.

scottaddie avatar Feb 05 '21 17:02 scottaddie

Open question: Should structs and interfaces be part of this series, or in the fundamentals section?

As an introduction to creating data types, they should at least be called out as possible data types. Perhaps a table that outlines some common usages of the types, so that at a glance the consumer can see when it might make sense to create a specific type of object.

IEvangelist avatar Feb 05 '21 17:02 IEvangelist

Moving this to December to update in the overall strategy of the fundamentals section.

BillWagner avatar Oct 21 '25 15:10 BillWagner