反射_程序集_额外补充2(将"123"转"壹贰叁"的stringbuilder打包成程序集类库的方法)
来源:互联网 发布:淘宝搜索权重模型 编辑:程序博客网 时间:2024/06/06 13:08
反射_程序集_额外补充2<18/9/2017>
using System;using System.Collections.Generic;using System.Linq;using System.Reflection;using System.Text;using System.Threading.Tasks;namespace 反射{ class Program { static void Main(string[] args) { //程序集 Assembly aa = Assembly.LoadFile(@"C:\Users\Maximilian Liu\Desktop\ClassLibrary1.dll");//使用LoadFile而不是Load Type[] tp = aa.GetTypes(); Console.WriteLine(tp.Length); object o = tp[0].GetConstructors()[0].Invoke(null); MethodInfo m = tp[0].GetMethod("M"); m.Invoke(o, new object[] { "123214" }); } }}ClassLibrary1.dll内容为下:(stringbuilder相关)
using System;using System.Collections.Generic;using System.Linq;using System.Text;namespace ClassLibrary1{ public class Class1 { public void M(string str)//123 -->> 一二三 { StringBuilder MyStringBuilder = new StringBuilder(str); //第二种用Append实现StringBuilder MyStringBuilder = new StringBuilder() string s = "零壹贰叁肆伍陆柒捌玖"; for (int i = 0; i < str.Length; i++) { int a = str[i] - 48; MyStringBuilder.Replace(str[i], s[a]); } //for (int i = 0; i < str.Length; i++) //{ // int a = str[i] - 48; // MyStringBuilder.Append(s[a]); //} Console.WriteLine(MyStringBuilder); } }}需要将该程序集版本改为framwork3.5,不然拿到unity中无法直接引用出命名空间
请参考作者另外一个和程序集相关的博客
阅读全文
0 0
- 反射_程序集_额外补充2(将"123"转"壹贰叁"的stringbuilder打包成程序集类库的方法)
- 反射_程序集_额外补充
- 反射_程序集_版本转换的两种方法(.Net Framework的版本)
- 反射_程序集
- 反射_程序集_打包库文件_引用库文件
- 1.Python补充_序列的方法
- Java程序的参数传递及项目打包成JAR文件_
- 构造方法_普通方法_成员变量的反射
- 计算器的程序_实验
- Ubuntu系统下的Hadoop集群(2)_使用命令行编译打包运行自己的MapReduce程序
- 【转】这也叫写程序*_*
- 脚本||程序_神马的_头大
- [ATL/WTL]_[初级]_[SDI程序关闭的注意事项]
- [并发并行]_[Windows]_[指定程序执行的CPU]
- 操作系统_内存管理_程序的装入和链接
- QT5的程序打包发布(将QT5的工程项目打包成一个exe程序)
- 实验1_了解C程序的运行环境和运行一个C程序的方法
- 使用install4j将jar打包成exe程序的方法详解
- 强化学习之Policy Gradient
- 1. linux C -- 进程锁
- SDWebImage的使用
- System 命名空间
- dubbo 后台管理dubbo-admin
- 反射_程序集_额外补充2(将"123"转"壹贰叁"的stringbuilder打包成程序集类库的方法)
- MetricsSystemImpl.register
- 提高代码质量-工具篇
- Python的练手项目有哪些值得推荐?
- jeecg框架日常开发问题解决方法
- bzoj3439: Kpm的MC密码(四种做法)
- 浅谈java的多线程
- 【C/C++】数组元素循环右移问题
- Android计算开机完成之后kernel所消耗的总的内存(不可回收)