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

推荐订阅源

CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
V
Visual Studio Blog
阮一峰的网络日志
阮一峰的网络日志
W
WeLiveSecurity
Google DeepMind News
Google DeepMind News
Help Net Security
Help Net Security
WordPress大学
WordPress大学
博客园_首页
大猫的无限游戏
大猫的无限游戏
Jina AI
Jina AI
The Cloudflare Blog
Hacker News - Newest:
Hacker News - Newest: "LLM"
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
T
Tenable Blog
Google Online Security Blog
Google Online Security Blog
PCI Perspectives
PCI Perspectives
博客园 - 三生石上(FineUI控件)
Recent Commits to openclaw:main
Recent Commits to openclaw:main
宝玉的分享
宝玉的分享
T
Tailwind CSS Blog
Forbes - Security
Forbes - Security
C
CERT Recently Published Vulnerability Notes
罗磊的独立博客
Security Latest
Security Latest
小众软件
小众软件
T
The Exploit Database - CXSecurity.com
C
Cisco Blogs
量子位
P
Privacy & Cybersecurity Law Blog
Schneier on Security
Schneier on Security
N
News and Events Feed by Topic
Apple Machine Learning Research
Apple Machine Learning Research
S
SegmentFault 最新的问题
V2EX - 技术
V2EX - 技术
C
Cyber Attacks, Cyber Crime and Cyber Security
Scott Helme
Scott Helme
Cisco Talos Blog
Cisco Talos Blog
S
Schneier on Security
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
V
Vulnerabilities – Threatpost
N
News and Events Feed by Topic
U
Unit 42
腾讯CDC
博客园 - 聂微东
博客园 - 【当耐特】
B
Blog
P
Proofpoint News Feed
B
Blog RSS Feed
www.infosecurity-magazine.com
www.infosecurity-magazine.com

博客园 - 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;
        }
    }
}