![](/img/trans.png)
[英]String.IsNullOrEmpty is not detecting the Escape sequence NULL \0 in C#
[英]Cannot perform runtime binding on a null reference on C# String.IsNullorEmpty in VS2019
您正在(可能)在 null動態類型上調用ToString
。
例如,它與以下場景相同:
dynamic s = null;
s.ToString(); // Cannot perform runtime binding on a null reference
一種解決方法是使用null 條件運算符,它將檢查null
的動態類型。
string.IsNullOrEmpty(s?.ToString());
或與您的示例相關:
string.IsNullOrEmpty(something.Cells[x,y].Value2?.ToString())
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.