单身数据访问层 [英] data access layer of singleton

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

问题描述

如何获取单例的数据访问层?

How to get data access layer of singleton ?

推荐答案

引用:

请查看此链接



Singleton


部分类允许将单个类划分为两个单独的物理文件。在编译期间,这些文件被编译到单个类中。例如,您可以在下图中看到我们将客户类划分为两个不同的文件math1.cs和math2.cs。



编译期间这些文件在内部编译成单个类。因此,当您创建客户类的对象时,您将能够看到两个物理文件中的方法。例如,您可以看到Add方法属于math1.cs,Delete方法属于math2.cs,但是当创建数学对象时,我们可以看到Add和Multiply方法。 br $>


公共类MyClass

{

数学对象=数学();

obj。

//点操作后你会得到Add,Multiply方法

}



公共部分类数学

{

public int add(int x,int y)

{

return x + y;

}

}



公共部分班级数学

{

public void Multiply(int x,int y)

{

返回x * y;

}

}
A partial class allows a single class to be divided in to two separate physical files. During compile time these files get compiled in to single class. For instance you can see in the below figure we have the customer class divided in to two different files "math1.cs" and "math2.cs".

During compilation these files gets compiled in to single class internally. So when you create an object of the customer class you will be able to see methods lying in both the physical files. For instance you can see "Add" method belongs to "math1.cs" and "Delete" method belongs to "math2.cs" , but when the math object is created we can see both "Add" and "Multiply" methods.

public class MyClass
{
Math obj=Math();
obj.
//You will get Add, Multiply methods after dot operation
}

public partial class Math
{
public int add(int x, int y)
{
return x+y;
}
}

public partial class Math
{
public void Multiply(int x, int y)
{
return x*y;
}
}


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

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