Individuals interpret interface as a special judgment technique, not as a conventional variable type such as judging a string, judging an array, but rather judging whether an instance of the class has certain properties or methods (such as having 10 women wearing the same clothes, covering the head, and letting the groom guess which is his bride, Although this application is seldom seen, but it does exist, Tong Pak-fu in his poetry, and then one of the women reacted, according to which he thought the response is the object he is looking for.
?
In the example program, we declare four kinds of drivers, although from the type of name to know that Danger_driver is illegal driving, but a finer distinction we do not know, such as truck_driver in the end is what kind of unclear, how to declare a unified method Drive_ Judgement, no matter what type of driver passes in, can give you back out what type he is (Driver_judgement can be understood as the same machine as the bride screening machine, no matter what woman, even if the head is covered with red cloth, as long as the machine a check, can determine whether the specified type , we here regardless of fat skinny, adults and children, as long as through this method of a check, you can determine what type of driver's license, can drive what car?
?
The passed-in type of the function is special, is an object (not a specified type, is any type), and then this arbitrary type goes in and attempts to cast to the type of the specified interface (essentially an attempt to cast to the specified type, which is understood to determine whether he has the specified interface, and if so, the conversion is complete, If not, then return null, of course, this application is very special, I did not think of any specific application must do so, for individuals to design this interface is very laborious, read, maintenance is very troublesome, personal not recommended to use)
?
?
For more instructional videos and downloads, please pay attention to the following information:
My Youku Space:
Http://i.youku.com/acetaohai123
?
My online forum:
http://csrobot.gz01.bdysite.com/
?
Problem Exchange:
qq:910358960
Email:[email protected]
?
?
C#. NET Frequently asked Questions (FAQ)-interface interface How to understand