c# 反射调用程序集方法、接口实例

本文演示了如何在C#中通过反射来调用程序集内的类、接口方法、属性、字段以及构造函数。示例展示了加载Webtest.dll,获取并实例化ReflectTest类,调用其公共和私有方法,设置和获取属性值,以及通过接口创建实例的过程。
摘要由CSDN通过智能技术生成

新建类库:Webtest

添加相应类:ReflectTest 接口interface1

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Webtest
{
    public interface interface1
    {
        int add();

    }
    public class ReflectTest : interface1
    {

        public String Write;
        private String Writec;

        public String Writea
        {
            get
            {
                return Write;
            }
            set
            {
                Write = value;
            }

        }

        private String Writeb
        {
            get
            {
                return Writec;
            }
            set
            {
                Writec = value;
            }

        }

        public ReflectTest()
        {
            this.Write = "Write";
            this.Writec = "Writec";
        }

        public ReflectTest(string str1, string str2)
        {
            this.Write = str1;
            this.Writec = str2;

        }

        public string WriteString(string s, int b)
        {

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值