English 中文(简体)
c 尚未发现的
原标题:c# identifier not found
  • 时间:2010-02-27 15:03:51
  •  标签:
  • c#
using System;

namespace it2b_project_01
{
    static class class1
    {
        static public class1()
        {
            InitializeComponent();
        }


        public static void error_check(object sender, EventArgs e)
        {
        }
    }
}

不同的.cs文件

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace it2b_project_01
{
    public partial class Create_an_Order : Form
    {
        public Create_an_Order()
        {
            InitializeComponent();
        }

        private void Create_an_Order_Load(object sender, EventArgs e)
        {

        }

        private void Order_Button_Submit_Click(object sender, EventArgs e)
        {
            class1.error_check();
        }
    }
}

创建一个Order.cs(26,13):错误CS0103:在当前上下文中不存在class1的名称。

问题回答

制作

static class class1

public static class class1

它无法找到,因为它不是公开的。

  1. 静态构造函数不允许使用public这样的访问修饰符,请从class1构造函数中删除public。

  2. 错误检查需要两个参数,您没有传递其中任何一个。

我做了这两件事情,它就符合要求了。





相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

NSArray s, Primitive types and Boxing Oh My!

I m pretty new to the Objective-C world and I have a long history with .net/C# so naturally I m inclined to use my C# wits. Now here s the question: I feel really inclined to create some type of ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

How to Use Ghostscript DLL to convert PDF to PDF/A

How to user GhostScript DLL to convert PDF to PDF/A. I know I kind of have to call the exported function of gsdll32.dll whose name is gsapi_init_with_args, but how do i pass the right arguments? BTW, ...

Linqy no matchy

Maybe it s something I m doing wrong. I m just learning Linq because I m bored. And so far so good. I made a little program and it basically just outputs all matches (foreach) into a label control. ...

热门标签