首页 > 其他 > 详细

Get Length 使用dynamic关键字

时间:2016-05-17 19:09:48      阅读:189      评论:0      收藏:0      [点我收藏+]

You don‘t have any idea what is the type of the input object, but you know that it has Length property.

(The input can be any type of object that has Length property)

So, the GetLength method should return the Length of input.

public class Kata
{
    public static int GetLength(object obj)
    {
        dynamic a = obj;
        return a.Length;
    }
}

 

Get Length 使用dynamic关键字

原文:http://www.cnblogs.com/chucklu/p/5502590.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!