简体   繁体   English

C# 错误 - 文件无法编译

[英]C# Errors - File wont compile

I have a code that I'm meant to compile into a .DLL file (it's for the game Call of Duty: Modern Warfare 3).我有一个代码,我打算编译成一个 .DLL 文件(它用于游戏《使命召唤:现代战争 3》)。 However, it wont compile.但是,它不会编译。 Any ideas?有任何想法吗? Thanks!谢谢!

using MapEdit;
using Addon;
using System;

namespace mp_terminal_cls
{
    public class mp_terminal_cls : MapEdit
    {
        public mp_terminal_cls()
        {
        }

        createfloor(new Vector(2263f,4406f,286f),new Vector(2958f,4147f,286f));

        public override void OnMapChange()
        {
            base.OnMapChange();
        }
    }
}

I get 7 errors, the problem is the original code was exactly the same.我收到 7 个错误,问题是原始代码完全相同。 I only added 2 new lines of code.我只添加了 2 行新代码。 Here is the errors:这是错误:

在此处输入图片说明

Sorry I'm quite new to C# I only have about 2 months experience with VB.对不起,我对 C# 很陌生,我只有大约 2 个月的 VB 经验。

1) Move the call to createfloor either into the constructor's body or OnMapChange 's body (from your code, we can't tell which one you need): 1) createfloor的调用移动到构造函数的主体OnMapChange的主体中(从您的代码中,我们无法确定您需要哪一个):

public mp_terminal_cls()
{
    createfloor(new Vector(2263f,4406f,286f),new Vector(2958f,4147f,286f));
}

or或者

public override void OnMapChange()
{
    createfloor(new Vector(2263f,4406f,286f),new Vector(2958f,4147f,286f));
    base.OnMapChange();
}

2) The base class MapEdit doesn't seem to have a OnMapChanged method. 2) 基类MapEdit似乎没有OnMapChanged方法。

As a side-note, your classes and namespaces should have distinct names, to avoid ambiguity issues.作为旁注,您的类和命名空间应该具有不同的名称,以避免歧义问题。

There are essentially two errors基本上有两个错误

  1. MapEdit is a namespace but is used as a type usually means that you have a class called MapEdit inside a namespace called MapEdit. MapEdit 是一个命名空间,但用作类型通常意味着您在名为 MapEdit 的命名空间中有一个名为 MapEdit 的类。 Refer to it as MapEdit.MapEdit.将其称为 MapEdit.MapEdit。
  2. The rest are caused by the call to CreateFloor not being inside a function.其余的原因是对 CreateFloor 的调用不在函数内部。 I assume that it should exist inside the constructor so move it inside我认为它应该存在于构造函数中,因此将其移入

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM