类无法访问 [英] Class is Not Accessing

查看:144
本文介绍了类无法访问的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨 我已经创建了一个网站,并创建了两个文件夹,一个是BAL(业务访问层),另一个是DAL(数据访问层)
在BAL中,我创建了此代码

Hi I have create a website and i have create two folders one is BAL(Business access layer) and other one is DAL(Data access layer)
In BAL i have created this code

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
    public class Employees
    {
        public Employees()
        { }
        public int ID { get; set; }
        public string FirstName { get; set; }
        public string LastName { get; set; }
        public string Address { get; set; }
        public string Number { get; set; }
    }


并且我在DAL中创建了类,并且尝试在DAL中创建以下代码
问题是,雇员类无法访问,并且还会列出<>无法在这里访问
我不知道为什么会这样


and i have create class in DAL and i am trying to create below code in DAL
problem is that Employees class is not accessing and also list<> not accessing here
i don''t know why it is happening can any one help me please

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

/// <summary>
/// Summary description for insert_customer
/// </summary>
public class insert_customer
{
	public insert_customer()
	{}
    public List<employees> insert_emp(Employees emp)
    {
        
    }
}


问题是,雇员类无法访问,并且还会列出<>无法在这里访问
我不知道为什么会这样.


problem is that Employees class is not accessing and also list<> not accessing here
i don''t know why it is happening can any one help me please

推荐答案

u应该在DAL中添加名称空间.
u should add name space in DAL .


朋友,在同一个命名空间中创建两个类,将解决您的问题.

谢谢,
Ambesha
Friend, create both the classes in the same namespace, will resolve your issue.

Thanks,
Ambesha




像下面这样写你的代码

Hi,

Write your code like below

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using DAL;

namespace BAL
{
    public class Employees
    {
        public Employees()
        { }
        public int ID { get; set; }
        public string FirstName { get; set; }
        public string LastName { get; set; }
        public string Address { get; set; }
        public string Number { get; set; }
    }
}



然后按如下所示编写您的DAL代码



And then write your DAL code as below

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using BAL;

namespace DAL
{
/// <summary>
/// Summary description for insert_customer
/// </summary>
public class insert_customer
{
    public insert_customer()
    {}
    public List<Employees> insert_emp(Employees emp)
    {

    }
}
}




您还应注意BAL和DAL文件夹都在同一项目中.
如果已将BAL和DAL创建为不同的项目,则还需要添加该项目的引用,以从其他项目访问该类.

希望对您有帮助.




One more thing you should take care that both BAL and DAL folder are in same project.
If you have created BAL and DAL as different project then you need to add reference of the project as well to access the class from other project.

Hope this will help you.


这篇关于类无法访问的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆