关于班级划分 [英] About class division

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

问题描述

你好朋友,
我定义了以下类

Hello friends,
I have defined class as below

public class UserDAO
{ 
     public clsUser Validate(string username,string pwd)
	{
        }
         
     public int saveUserDetails(clsUser objUser)
        { 
        }

     public DataSet GetUserDetails()
        {
        }
}



我可以知道,在上述情况下我需要继承吗?
只是想知道继承是如何实现的

在此先谢谢您



May i know, do I require inheritance in above scenario??
Just trying to know how actually inheritance is implemented

Thanks in advance

推荐答案

在上述情况下您不必使用继承,继承通常是有起点的.

例如,如果您从TextBox对象继承一个类,则您的类与TextBox类完全相同
You don''t have to use inheritance in the above scenario, inheritance is used to kind of have a starting point.

For example if you inherit a class from a TextBox object, your class is exactly the same as the TextBox class
public class MyCustomTextbox : System.Windows.Forms.Textbox
{
}



您可以使用继承向现有类型添加或操作功能.在此示例中,您可以向TextBox控件添加或修改功能,例如Validation或其他功能.

玩得开心,

爱德华



You can use inheritance to add or manipulate functionality to an existing type. In this example you can add or modify functionality to the TextBox control, for example Validation or something.

Have fun,

Eduard


请阅读这些

http://msdn.microsoft.com/en-us/library/ms173149 (v = vs.80).aspx [ http://www.csharp-station.com/Tutorials/lesson08.aspx [ ^ ]
Please read these

http://msdn.microsoft.com/en-us/library/ms173149(v=vs.80).aspx[^]
http://www.csharp-station.com/Tutorials/lesson08.aspx[^]


它"严格不可能回答这个问题.

您所问的问题类似于我需要汽油才能开车去商店吗?"
答案取决于太多未指定的内容:
1)您有汽车或摩托车吗?
2)它有足够的燃料去商店吗?
3)它可以在柴油上运行吗?
4)附近有加油站吗?
5)您是在没有桥梁的岛上还是商店?

您需要继承任何东西吗?如图所示,您的类中没有任何东西需要继承,但是只有很小的片段就无法可靠地说出.
It''s not strictly possible to answer that.

The question you have asked is similar to "Do I need petrol to drive to the shops?"
The answer depends on too many unspecified things:
1) Do you have a car or motorcycle?
2) Does it have enough fuel to get to the shops?
3) Does it run on diesel?
4) Is there a petrol station nearby?
5) Are you or the shops on an island with no bridge?

Do you need to inherit from anything? There is nothing in your class as shown which needs to inherit, but with just a tiny fragment nothing can be reliably said.


这篇关于关于班级划分的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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