相关疑难解决方法(0)

为什么空合并运算符(??)在这种情况下不起作用?

NullReferenceException当我运行此代码时,我发现了一个意外,省略了fileSystemHelper参数(因此将其默认为null):

public class GitLog
    {
    FileSystemHelper fileSystem;

    /// <summary>
    ///   Initializes a new instance of the <see cref="GitLog" /> class.
    /// </summary>
    /// <param name="pathToWorkingCopy">The path to a Git working copy.</param>
    /// <param name="fileSystemHelper">A helper class that provides file system services (optional).</param>
    /// <exception cref="ArgumentException">Thrown if the path is invalid.</exception>
    /// <exception cref="InvalidOperationException">Thrown if there is no Git repository at the specified path.</exception>
    public GitLog(string pathToWorkingCopy, FileSystemHelper fileSystemHelper = null)
        {
        this.fileSystem = fileSystemHelper ?? new FileSystemHelper(); …
Run Code Online (Sandbox Code Playgroud)

c# null-coalescing-operator

15
推荐指数
1
解决办法
1473
查看次数

标签 统计

c# ×1

null-coalescing-operator ×1