c# - 找不到 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#的初学者请解释一下
解决方案
ArgumentNullException位于“系统”命名空间中。所以要么完全限定名称,
throw new System.ArgumentNullException("newLocation");
或添加
using System;
到 C# 文件或命名空间的顶部。
推荐阅读
- javascript - 在按钮单击时以编程方式将焦点移至文本字段
- c# - 参数类型不匹配,DateTime 和 DateTime
- php - 在 10 月 cms 中显示验证消息中的图像索引
- sql - 根据条件更新列并为每次更新在另一个表中创建一个新行
- python - 多个属性的相同 GET 属性
- matlab - 生成 1-10 的正态分布随机整数并在 simulink 中使用
- java - Java TableView 不只填充一列
- r - 循环“ifelse”,包括 NA
- javascript - 您可以将 FileInterceptor 与 TransformPipe 一起使用吗
- python - 如何计算熊猫数据框中具有循环依赖的列?