现在的位置: 首页 > 综合 > 正文

昨天忽然发现被加到training团队中了,遂来发一篇。

2011年11月03日 ⁄ 综合 ⁄ 共 712字 ⁄ 字号 评论关闭

最近也在带几个人,算是新手吧,前天给他们出了一道题给他们思考,现在贴到这里,注意注掉的部分。

答案很明显的,不明白的仔细思考。

using System;

using System.Collections;


namespace Training.Sample

{

    
internal abstract class Vehicle

    
{

//        public override bool Equals(object obj)

//        {

//            return false;

//        }

    }



    
internal class Truck : Vehicle

    
{}


    
public sealed class Sample

    
{

        
public static void Main(string[] args)

        
{

            Vehicle vehicle 
= new Truck();


            ArrayList vehicles 
= new ArrayList();


            vehicles.Add(vehicle);


            Truck truck 
= vehicle as Truck;

//            Truck truck = (Truck) vehicle;



            Console.WriteLine(vehicles.Contains(truck));


            Console.ReadLine();

        }


    }


}


抱歉!评论已关闭.