为什么我们需要类逻辑? [英] why we need class logic ?

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

问题描述

为什么我们需要在C Sharp中使用类逻辑?
使用类可以获得什么机会?

Why we need class logic in C Sharp ?
What opportunities do we gain with classes ?

推荐答案

为什么我们需要在C Sharp中使用类逻辑?

类别"一词本身的意思是类别" /分区"

想象没有橱柜的图书馆
容易管理吗?否

与项目(名称空间)具有类的概念一样,可以轻松地管理代码".

最主要的是您可以根据要求管理名称空间中的类(代码块)
就像在图书馆一样,您可以用许多不同的方式布置橱柜.
例如.
Why we need class logic in C Sharp ?

The word ''class'' itself mean to ''category''/''Partition''

imagine library without cupboards
will it be easy to manage? NO

same way a project(name-space) have concept of class to manage ''codes'' easy way.

the main thing is you can manage classes(code-blocks) in namespace as per requirement
like in library you can arrange cupboards in many different ways.
eg.
library
   IT-dept
   EC-Dept
   GK-Dept


library
   syllabus books
      IT-dept
      EC-Dept
      GK-Dept
   Reference books 
      IT-dept
      EC-Dept
      GK-Dept



我们从课堂中获得什么机会?

一个主要机会是它有能力充当模板",
表示您可以创建类的实例/对象.

假设您有一本固定格式的帐单",则内容将随着客户的变化而在页面上发生变化.因此,帐单"是类,而不同的页面是对象

第二个是可重用性的概念(称为继承)

与班级有关的其他一些概念是
辅助功能
封装
覆盖
重载
继承(接口和类)
抽象类


对这些相关概念的深入研究将帮助您很好地利用类"/代码块".
如果以良好的方式管理类,则项目/应用程序/命名空间将反映所需的结果.

祝您编码愉快!
:)



What opportunities do we gain with classes ?

one main opportunity is it has ability to work as ''Template'',
means you can create instance/object of class.

suppose you have a ''bill book'' has a fixed format the content will be change on pages as the customer will changed. so, ''bill-book'' is class and different pages are the objects

second is the concept of re-usability (called Inheritance)

some other concepts related to class are
accessibility
encapsulation
overriding
overloading
inheritance (interfaces & class)
abstract class
etc.

Deep study of these related concepts will help you to utilize ''class''/''Code-blocks'' very well.
and if classes managed in good way, project/application/namespace will reflect desired results.

Happy Coding!
:)


似乎您是编程世界的新手.我们不需要类,不是每种语言都是面向对象的,但是它们允许我们将逻辑划分为执行不同任务的部分,这在设计系统时有很大帮助.

这个论坛不是您的最佳选择,我们希望可以帮助程序员解决特定的问题.我的简短答复不会告诉您所有您需要知道的内容,因此请阅读您的课堂课文,与您的老师交谈或学习如何使用Google查找有关您正在学习的内容的文章.某人永久写在网络上的一篇文章肯定比我愿意花5分钟来帮助您解决的5分钟要详细得多.
It seems you''re new to the programming world. We don''t NEED classes, not every language is OO, but they allow us to partition our logic in to sections that do different things, which helps greatly in designing systems.

This forum is not the best place for you, we expect to help programmers with specific questions. My brief reply won''t tell you all you need to know, so read your class texts, talk to your teacher, or learn how to use google to find articles on the things you are studying. An article that someone wrote to put on the web permanently is bound to contain a lot more detail than the 5 minutes of my life that I was willing to spend trying to help you could ever cover.



在每种情况下某个自定义工具生成类的一部分的每种情况下,它都是非常有用的,因为它允许您在不继承生成的类的情况下向生成的代码添加自定义逻辑.

这不仅与UI有关,而且其他技术(如Linq-To-Sql或Entity Framework)也大量使用此功能.

请参考 [
Hi,
It is very useful in every scenario where one part of class is generated by some custom tool because it allows you to adding custom logic to generated code without inheriting the generated class.

It is not only about UI but also other technologies like Linq-To-Sql or Entity Framework use this quite heavily.

Refer this[^] for more information about classes.

--Amit


这篇关于为什么我们需要类逻辑?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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