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. Redis之List类型操作

    接口: package com.net.test.redis.base.dao; import java.util.List; /** * @author *** * @Time:2017年8月10日 ...

  2. 1 > 2 and 3 < 4 or 4 > 5 and 2 > 1 or 9 < 8

    a,b,c,d,e,f,g=1,2,3,4,5,8,9 m = a > b and c < d or c > e n = b > a or g < f x = m and ...

  3. stark组件前戏(3)之django路由分发的本质include

    django路由分发的三种方式 方式一: from django.urls import re_path, include urlpatterns = [ re_path(r'^web/', incl ...

  4. iOS SDK中使用NSXMLParser解析XML(iphone网络篇三)

    iOS SDK的NSXMLParser解析XML文档是事件驱动模式的,即采用SAX方式来解析XML格式文档.NSXMLParser在处理XML文档的过程中当遇到一些要素(元素.属性.CDATA块.评论 ...

  5. Kilani and the Game CodeForces - 1105D (bfs)

    Kilani is playing a game with his friends. This game can be represented as a grid of size n×mn×m, wh ...

  6. Girls and Boys-hdu 1068

    Girls and Boys Time Limit: 20000/10000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) ...

  7. 安装ANSYS19.0的正确方法(附下载)

    安装ANSYS19.0的正确方法 卸载干净旧版本ANSYS 安装或重新安装之前必须先卸载干净,安装过旧版本ANSYS的也要确保卸载干净.电脑环境准备参考以下内容 ANSYS 卸载后重装需要注意的问题_ ...

  8. A1031 Hello World for U (20)(20 分)

    A1031 Hello World for U (20)(20 分) Given any string of N (>=5) characters, you are asked to form ...

  9. [Poj2761]Feed the dogs(主席树)

    Desciption 题意:求区间第K小(N<=100000) Solution 主席树模板题 Code #include <cstdio> #include <algorit ...

  10. spark测试几个hadoop的典型例子

    1.求每年的最高温度数据格式如下: 0067011990999991950051507004888888889999999N9+00001+999999999999999999999900670119 ...