How do I convert a C# string to a Span? (Span)

Span<T> and friends are included in .NET Core 2.1, so no additional NuGet package needs to be installed. Dan Sorensen’s answer was correct at that date and based on the preview, but now it is outdated. For string, the extension methods are AsSpan and AsMemory, that return ReadOnlySpan<char> and ReadOnlyMemory<char> respectively. Explicit AsReadOnlySpan is gone, … Read more

Check if value tuple is default

If you really want to keep it returning default, you could use result.Equals(default) the built-in Equals method of a ValueTuple should work. As of C# 7.3 value tuples now also support comparisons via == and != fully, Meaning you can now also do result == default and it should work the same.

What is the use case for the (C# 7.2) “private protected” modifier?

Before C# 7.2 we had protected internal modifier. This really means protected OR internal, that is – member A is accessible to child classes and also to any class in the current assembly, even if that class is not child of class A (so restriction implied by “protected” is relaxed). private protected really means protected … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)