Question: Convert error occurs with null-conditional, null-forgiving, and extension method when update VS to 16.8 #4129
-
Hi, folks: I write a extension method that convert null to default string like this: public static string ToStringOrDefault(this object obj, string defaultValue) {
//When obj is null then returns defaultValue.
} And I use the extension like this: using System.Xml.Linq;
XElement rootNode = XDocument.Parse("some XML text...").Root;
bool someNode = rootNode.Element("some Node name...")?.Value!.ToStringOrDefault("N").Contains("Y"); Everything is ok in VS 16.7 + .NET Core 3.1. Could someone tell me what happend? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 6 replies
-
Beta Was this translation helpful? Give feedback.
-
If your extension method accepts a null |
Beta Was this translation helpful? Give feedback.
#3393