惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Recorded Future
Recorded Future
小众软件
小众软件
C
Check Point Blog
MyScale Blog
MyScale Blog
V
Visual Studio Blog
博客园_首页
J
Java Code Geeks
人人都是产品经理
人人都是产品经理
腾讯CDC
云风的 BLOG
云风的 BLOG
爱范儿
爱范儿
量子位
N
Netflix TechBlog - Medium
宝玉的分享
宝玉的分享
博客园 - 叶小钗
H
Help Net Security
T
The Blog of Author Tim Ferriss
月光博客
月光博客
博客园 - 三生石上(FineUI控件)
P
Proofpoint News Feed
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
WordPress大学
WordPress大学
美团技术团队
有赞技术团队
有赞技术团队
Microsoft Azure Blog
Microsoft Azure Blog
IT之家
IT之家
M
MIT News - Artificial intelligence
S
Secure Thoughts
U
Unit 42
Google Online Security Blog
Google Online Security Blog
L
LINUX DO - 最新话题
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
Recent Announcements
Recent Announcements
F
Full Disclosure
The GitHub Blog
The GitHub Blog
V2EX - 技术
V2EX - 技术
D
DataBreaches.Net
Webroot Blog
Webroot Blog
Y
Y Combinator Blog
The Last Watchdog
The Last Watchdog
aimingoo的专栏
aimingoo的专栏
W
WeLiveSecurity
Blog — PlanetScale
Blog — PlanetScale
博客园 - 聂微东
Martin Fowler
Martin Fowler
阮一峰的网络日志
阮一峰的网络日志
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
V
V2EX
T
Tailwind CSS Blog
Application and Cybersecurity Blog
Application and Cybersecurity Blog

博客园 - angushine

获得本机IP地址 设置eclipse文件默认的编码方式 Eclipse Helios的PermGen space错误的解决办法 取指定长度的字符串(双字节算2) - angushine - 博客园 截取指定长度字符串 Silverlight项目无法启动调试 增强 VSS 的文件共享安全性 兼容各个版本浏览器的设置最小宽度 动态分配一维数组 浏览器区别 封装log4net C#获得调用方法的名称和类名 jQuery全选/全消CheckBox以及JS回调一例 MySQL绿色安装方法1 WebBrowser中调用加载页面的Javascript方法 定时更新内存和虚拟内存 多线程中更新组件 Request、Request.QueryString、Request.Form与Request.Params 开始→运行→输入的命令集锦(转载)
反射调用静态方法
angushine · 2009-10-12 · via 博客园 - angushine

using System;
using System.Collections.Generic;
using System.Text;
using System.Reflection;namespace ConApp
{
    
class Program
    {
        
static void Main(string[] args)
        {
            
// 使用TryParse,出现异常时,赋值为最小值
            string str = "4x";
            DateTime dt 
= DateTime.MaxValue;
            DateTime.TryParse(str, 
out dt);// 使用TryParse,出现异常时,赋值为最小值
            int i = 2;
            
int.TryParse(str, out i);// 调用静态方法
            Type t = typeof(Sys);
            
object obj = t.InvokeMember("GetName",
                    BindingFlags.InvokeMethod 
| BindingFlags.Static | BindingFlags.Public, nullnullnew object[] { 2 });// 调用一般方法
            Type type = typeof(Sys);
            Object objT 
= type.InvokeMember(null, BindingFlags.DeclaredOnly | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.CreateInstance, nullnull, args); 
            
int ii = (int)type.InvokeMember("GetInt", BindingFlags.InvokeMethod | BindingFlags.Public | BindingFlags.Instance, null, objT, new object[] { 1 }); 

            Console.ReadKey();
        }
    }

public class Sys
    {
        
public static string GetName(int id)
        {
            
return string.Format("Your name is : test_{0}", id + 1);
        }
public int GetInt(int value)
        {
            
return value + 100;
        }
    }
}