首页 > 解决方案 > 找不到 C# ArgumentNullException 类型或命名空间。VS 代码

问题描述

我的代码的一部分:

 public void Move(Point newLocation)
    {
        if (newLocation == null)
            throw new ArgumentNullException("newLocation");

        Move(newLocation.X, newLocation.Y);
    }

我将此视为错误

找不到类型或命名空间名称“ArgumentNullException”(您是否缺少 using 指令或程序集引用?)

我的 c# 代码有问题吗?这可能是 VS Code C# 支持扩展错误吗?

我是c#的初学者请解释一下

标签: c#visual-studio-codeargumentnullexception

解决方案


ArgumentNullException位于“系统”命名空间中。所以要么完全限定名称,

throw new System.ArgumentNullException("newLocation");

或添加

using System;

到 C# 文件或命名空间的顶部。


推荐阅读