简体   繁体   中英

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). 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. I only added 2 new lines of code. Here is the errors:

在此处输入图片说明

Sorry I'm quite new to C# I only have about 2 months experience with 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):

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.

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. Refer to it as MapEdit.MapEdit.
  2. The rest are caused by the call to CreateFloor not being inside a function. I assume that it should exist inside the constructor so move it inside

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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