所有OOPS概念必须使用哪个 [英] Which all OOPS concept must use

查看:65
本文介绍了所有OOPS概念必须使用哪个的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



i我正在用c#(mvc4)开发一个项目。我正在进行学习过程,以下是我的方案。



1.有公司名单

2.每家公司都有一些共同的特征,如产品类型,公司营业额,没有员工


这是在C#中使用的最佳创意。我使用Interface来声明

产品()

营业额()

NoOfStaffs()



或带有所有这些方法的类。请给我一个结构。

Hi,
i am developing a project in c# (mvc4).I am undergoing a learning process, the following is my scenario.

1. There are a list of Companies
2. Each Company has some common features like type of products,turnover of the company,no of staffs

Which is the best ideas to use in C#.Shall i use Interface for declaring
products()
turnover()
NoOfStaffs()

or a class with all these methods.Please give me a structure to follow.

推荐答案

如果您有其他对象与您的公司对象进行交互,并且您不需要关心这些对象如何实现事物,那么您将选择接口。



为什么不使用简单的属性?

If you have other objects interacting with your company object, and you don't need to care how those objects implement things, you'd go for interface.

Why not use simple properties?
class Company
{
turnover
{
get;set;
}

staffCount
{
get;set;
}
List<product> productList;
}
//And other properties go here that you link with member variables.

Class Product
{
int productID;
string productName;
.
.

}</product>





顺便说一下,你的目的是学习MVC上的OOP或OOP (Asp.net)?

如果您想学习OOPS,请坚持使用控制台应用程序,使您免受其他框架(MVC)布线和调试的影响。



btw, your intention is to learn just OOPs or OOPs on MVC (Asp.net)?
If you would like to learn OOPS, stick with Console Applications that spares you from other framework (MVC) wiring and debugging.


这篇关于所有OOPS概念必须使用哪个的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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