dynamic:

void Main()
{
var b="2";
dynamic a="2";
if(a.GetType()==typeof(int))b+=a;
if(a.GetType()==typeof(string))b+=a;
Console.WriteLine (b);
Console.WriteLine (GetName(1));
Console.WriteLine (GetName(2));
} // Define other methods and classes here
dynamic GetName(int a){
dynamic ret;
if(a==1)ret=2;
else ret="b";
return ret;
}

  

c# dynamic,maybe I should say it is just some shortcut for "Object", box and unbox, without the cast的更多相关文章

  1. Linux Programe/Dynamic Shared Library Entry/Exit Point && Glibc Entry Point/Function

    目录 . 引言 . C/C++运行库 . 静态Glibc && 可执行文件 入口/终止函数 . 动态Glibc && 可执行文件 入口/终止函数 . 静态Glibc & ...

  2. 浅谈Dynamic 关键字系列之一:dynamic 就是Object(转)

    C# 4.0提供了一个dynamic 关键字,那么什么是dynamic,究竟dynamic是如何工作的呢? 从最简单的示例开始: static void Main(string[] args) { d ...

  3. MyBatis(3.2.3) - Dynamic SQL

    Sometimes, static SQL queries may not be sufficient for application requirements. We may have to bui ...

  4. Create Dynamic Modal Dialog Form in AdminLTE Bootstrap template

    原文地址 Create modal dialog form in jquery using bootstrap framework, slightly different from the usual ...

  5. C# 4.0 新特性-dynamic 【转】

    前段时间看过一些关于dynamic这个C#4中的新特性,看到有些朋友认为dynamic的弊大于利,如无法使用编译器智能提示,无法在编译时做静态类型检查,性能差等等.因此在这篇文章中我将就这些问题来对d ...

  6. [CLR via C#]5.4 对象哈希码和dynamic基元类型

    原文:[CLR via C#]5.4 对象哈希码和dynamic基元类型 FCL的设计者认为,如果能将任何对象的任何实例放到一个哈希表集合中,会带来很多好处.为此,System.Object提供了虚方 ...

  7. c# 确定dynamic类型的数据对象是否存在某个属性

    public static bool IsPropertyExist(dynamic data, string propertyname)   {     if (data is ExpandoObj ...

  8. c++ Dynamic Memory (part 1)

    1. make_shared<T>(args): return a shared_ptr dynamically allocated object of type T. Use args ...

  9. .net4 dynamic parse xml

    using System.Collections.Generic; using System.Linq; using System.Xml.Linq; using System.Dynamic; na ...

随机推荐

  1. python 使用uuid 出现重复

    同时保存入数据库时候 ,使用  uuid.uuid1() 后出现 重复的 id , 现在  修改为 (uuid.uuid5(uuid.NAMESPACE_DNS, str(uuid.uuid1()) ...

  2. ethtool查看网卡以及修改网卡配置

    ethtool 命令详解 命令描述: ethtool 是用于查询及设置网卡参数的命令. 使用概要:ethtool ethx       //查询ethx网口基本设置,其中 x 是对应网卡的编号,如et ...

  3. LeetCode954二倍数对数组

    问题:二倍数对数组 给定一个长度为偶数的整数数组 A,只有对 A 进行重组后可以满足 “对于每个 0 <= i < len(A) / 2,都有 A[2 * i + 1] = 2 * A[2 ...

  4. IE支持直接查看Json数据注册表代码

    Windows Registry Editor Version 5.00 [HKEY_CLASSES_ROOT\MIME\Database\Content Type\application/json] ...

  5. Table 分页处理

    介绍两种table分页处理:PHP分页 和 js(jquery.table)分页. 一:jquery.table: 1:下载两个文件:table_jui.css 和 jquery.dataTables ...

  6. Charles Babbage【查尔斯·巴贝奇】

    Charles Babbage When Babbage was working at Cambridge, a new idea occurred to him. 巴贝奇在剑桥工作的时候,脑海中有了 ...

  7. 【树状数组】CF961E Tufurama

    挺巧妙的数据结构题(不过据说这是一种套路? E. Tufurama One day Polycarp decided to rewatch his absolute favourite episode ...

  8. hadoop 启动or运行mr错误

    hadoop 错误:Incorrect configuration: namenode address dfs.namenode.servicerpc-address or dfs.namenode. ...

  9. 10,Scrapy简单入门及实例讲解

    Scrapy是一个为了爬取网站数据,提取结构性数据而编写的应用框架. 其可以应用在数据挖掘,信息处理或存储历史数据等一系列的程序中.其最初是为了页面抓取 (更确切来说, 网络抓取 )所设计的, 也可以 ...

  10. “帮你APP”团队冲刺1

    1.整个项目预期的任务量 (任务量 = 所有工作的预期时间)和 目前已经花的时间 (所有记录的 ‘已经花费的时间’),还剩余的时间(所有工作的 ‘剩余时间’) : 所有工作的预期时间:88h 目前已经 ...