使用虚拟关键字定义类 [英] Use of Virtual Keyword in defining the Class

查看:94
本文介绍了使用虚拟关键字定义类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,


在一些MVC示例(代码优先方法)中,在为Databace定义类时,我发现了这样的语句,如
公共虚拟< classname>标识符{get; set;}"或公共虚拟ICollection< classname>标识符{get; set;}".

谁能告诉我使用带有虚拟关键字的此类语句的确切用法..

示例:http://gentlelogic.blogspot.in/2012/03/entity-framework-code-first-first.html

在此先感谢...

Hi all,


In some MVC Examples(Code First Approach), during defining the class for Databace, I found the statement like as
"Public Virtual <classname> Identifier{get;set;}", or "Public Virtual ICollection<classname> Identifier{get;set;}".

Can any one tell me the exact use of using such kind of statements with Virtual Keyword..

Example:http://gentlelogic.blogspot.in/2012/03/entity-framework-code-first-first.html

Thanks in advance...

推荐答案

这是OOP的核心.可以说,如果您不理解它,那么您将不懂OOP.看来您需要停止做自己的工作并学习它,否则使用类进行进一步的编程几乎没有用.

一些获得想法的材料:
http://en.wikipedia.org/wiki/Virtual_function [ http://en.wikipedia.org/wiki/Dynamic_dispatch [ http://en.wikipedia.org/wiki/Late_binding [http://en.wikipedia.org/wiki/面向对象的程序 [
This is the very heart of OOP. One can say, if you don''t understand it, you have no idea of OOP. It looks like you need to stop doing what you are doing and learn it, otherwise further programming with classes are pretty much useless.

Some material to get an idea:
http://en.wikipedia.org/wiki/Virtual_function[^],
http://en.wikipedia.org/wiki/Dynamic_dispatch[^],
http://en.wikipedia.org/wiki/Late_binding[^],
http://en.wikipedia.org/wiki/Object-oriented_programming[^].

—SA


这篇关于使用虚拟关键字定义类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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