AngryHacker
AngryHacker

Reputation: 61636

Is it possible for a .NET Standard library to access .NET Core methods?

.NET Core has a method with the following signature:

.Replace(string old, string @new, StringComparison comp)

while .NET Standard only has this method.

.Replace(string old, string @new)

It feels odd to be able to use the .NET Core version of it in a web project, but not in a library project that is referenced.

I suspect the answer to my question is no, but want to be sure.

Upvotes: 0

Views: 284

Answers (1)

Jon Skeet
Jon Skeet

Reputation: 1502306

No, if it's only in .NET Core, you can't use it from .NET Standard.

It feels odd to be able to use the .NET Core version of it in a web project, but not in a library project that is referenced.

Why does it feel odd? .NET Core is fundamentally a bigger API surface area than .NET Standard, so you should expect there to be things you can use from Core but not Standard.

There's nothing to stop you from making your library target .NET Core if you want - it just won't be compatible with (say) desktop .NET.

Upvotes: 6

Related Questions