c# - The type or namespace name 'davetrainer' could not be found (are you missing a using directive or an assembly reference?)
问题描述
I'm new to C#, just programming for fun honestly, and I'm trying to create an object using a class in another file from my main one (my main file is called hello.cs, and the other file is called trainer.cs). They're both in the same folder, but when I try compiling hello.cs in the command line (using a path w/ .net), I get the error message in the title. I'm not using Visual Studio or a program like that, so a lot of answers I've found online don't really help.
This is my main file code:
using System;
using davetrainer;
namespace daveprogram {
class Sure {
public int addition(int a, int b) {
return a + b;
}
static void Main() {
Trainer dave = new Trainer("Dave", "water");
Console.WriteLine("Hello!");
}
}
}
and this is trainer.cs:
using System;
namespace davetrainer {
public class Trainer {
string name;
string spec;
public Trainer(string a, string b) {
name = a;
spec = b;
}
}
}
Any help would be appreciated!
解决方案
推荐阅读
- visual-studio - 提交更改从自动更改中显示。我怎样才能只看到我所做的更改?
- postgresql - Doobie 在通用上下文 F 的事务中运行多个效果 f1 和 f2?
- javascript - 传递 foreach 键时单击按钮时未捕获的引用错误
- python - 使用 django、celery 和 redis 的一项一项任务
- vue.js - 如何在服务文件 quasar vue 中调用路由器
- python - 'has_3([1, 3, 3])' 在 Python 中是什么意思?
- android - Amazon 简单通知服务 (SNS) - 如何发布消息以通过其 arn 或令牌指定端点
- jquery - CSS scroll-snap-type 与水平滚动
- api - 在发送之前使用 Adobe Sign API 在模板中填充表单字段
- c# - 有没有办法确保从 ac# 方法返回的值分配给变量?