program.cs

来自「一个通讯录源码,用C#写的.挺不错的,大家可以参考看一下.」· CS 代码 · 共 56 行

CS
56
字号
using System;
using System.Collections.Generic;
using System.Windows.Forms;
using System.Reflection;
using System.Reflection.Emit;
using System.Threading;

namespace AddressList
{
    static class Program
    {
        /// <summary>
        /// 应用程序的主入口点。
        /// </summary>
        [STAThread]
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            Assembly assem = Assembly.GetExecutingAssembly();        


            // Create an object from the assembly, passing in the correct number
            // and type of arguments for the constructor.
            //Object o = assem.CreateInstance("Example", false,
            //    BindingFlags.ExactBinding,
            //    null, new Object[] { 2 }, null, null);

            // Make a late-bound call to an instance method of the object.    
            //MethodInfo m = assem.GetType("Example").GetMethod("SampleMethod");
            //Object ret = m.Invoke(o, new Object[] { 42 });
            

            //fmLogin login = new fmLogin();
            
            //取得类型 
            Type objType = assem.GetType("AddressList.Forms.fmLogin", true, true); 
            //Type objType = Type.GetType("AddressList.fmLogin"); 
            //定义构造函数信息
            ConstructorInfo objCtor = objType.GetConstructor(Type.EmptyTypes);//Type.EmptyTypes

            //调用构造函数,并把返回结果强转为Form
            Form login = (Form)objCtor.Invoke(null);

            if (login != null)
            {
                login.ShowDialog();
                if (login.DialogResult == DialogResult.Yes)
                    Application.Run(new Forms.fmAddressData());
            }
            else
                Application.Exit();
        }
    }
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?