In a saucepan, heat the milk over medium heat until just simmering.
In a separate bowl, whisk together the egg yolks and sugar until pale and thick.
Add cornstarch to the egg mixture and whisk until smooth.
Gradually pour the hot milk into the egg mixture, whisking constantly.
Return the mixture to the saucepan and cook over medium heat, stirring continuously until thickened.
Remove from heat and stir in the butter, vanilla extract, and salt.
Strain the pastry cream through a sieve to remove lumps.
Cover the surface with plastic wrap to prevent a skin from forming.
Let it cool at room temperature, then refrigerate until set.
Serve as a filling for pastries, cakes, or enjoy on its own.