mt12
mt12

Reputation: 1

c# identifier not found

using System;

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


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

(different .cs file)

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();
        }
    }
}

Create an Order.cs(26,13): error CS0103: The name 'class1' does not exist in the current context.

Upvotes: 0

Views: 868

Answers (2)

rerun
rerun

Reputation: 25505

  1. Access modifiers like public are not allowed on static constructors so drop the public from the class1 constructor.

  2. error check takes 2 paramters which your not passing in.

I did those two things and it complied.

Upvotes: 1

JDMX
JDMX

Reputation: 1509

make

static class class1

public static class class1

it cannot find it because it is not public

Upvotes: 1

Related Questions