解释C#中的包装器类和方法 [英] Explain wrapper class and methods in C#

查看:552
本文介绍了解释C#中的包装器类和方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好

任何人都可以解释什么是WRAPPER类和方法,以及在我的asp.net Web应用程序中如何使用这些类和热点实现



预先感谢

Hi All

Can any one explain what is WRAPPER class and method and what is the use of these and hot to implement in my asp.net web application



Thank''s in advance

推荐答案

包装器类是包装"或封装"另一个类或组件功能的任何类.这提供了对基础类的实现的抽象级别,并隐藏"了来自外部世界的实现.
例如,如果编写音乐播放器,则可能会有一个Track类,该类处理它在磁盘上的位置,乐队名称,专辑等.但是,您还需要一个播放列表:可以很容易地将其作为List<Track>.但是,创建一个名为Playlist的包装器"类可能更有意义,该类包含一个轨道列表,但是公开了Add和Remove方法,该方法也有一个名称,并且知道如何将自身保存/加载到磁盘.由于实际的列表是对外界隐藏的,因此,如果您不知道该内容并知道需要保存该列表,他们便无法更改内容.
A wrapper class is any class which "wraps" or "encapsulates" the functionality of another class or component. This provides a level of abstraction from the implementation of the underlying class and "hides" the implementation from the outside world.
For example, if you write a music player, you would probably have a Track class which handles where it is on disk, the band name, album, and so forth. But you would also want a playlist: which could be a List<Track> quite easily. But it might make more sense to create a "wrapper" class called Playlist which contains a list of tracks, but exposes the Add and Remove methods, which also has a name and knows how to save / load itself to disk. Because the actual List is hidden from the outside world, they can''t change the content without you knowing about it and being aware that the list needs to be saved.


这篇关于解释C#中的包装器类和方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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