---
title: "Inheritance and constraints"
date: "2026-03"
category: "Design Patterns & Architecture"
tags: ["Design Patterns & Architecture"]
description: "This part is kind of interesting, inheritance and constraints seem to overlap a little, and when you get down to it, inheritance itself also means inheriting the structure itself..."
source: "https://enriquemark.com/en/posts/%E7%BB%A7%E6%89%BF%E5%92%8C%E7%BA%A6%E6%9D%9F"
---

This part is kind of interesting, inheritance and constraints seem to overlap a little, and when you get down to it, inheritance itself also means inheriting the structure itself, which is essentially a constraint. It's just that ts is more flexible, it's duck typing, so matching structure is enough, but in C# it has to be inheritance.

```TS
// TypeScript
// extends here implies inheritance, but matching structure passes the check too
function foo<T extends JobBase<T>>() {}

// C# equivalent
// but here it has to be inheritance
void Foo<T>() where T : JobBase<T> {}
```

---

**Translation note.** I wrote this in Chinese. This English version is an LLM translation, so the wording is not mine even though the thinking is. Original: [继承和约束](</zh-hant/posts/继承和约束>).
