C#高级特性(反射)

2023-05-16

今天来讲解反射的应用:

一、反射是什么?
简诉一下,反射就是.Net Framework 的一个帮助类库,可以获取并使用metadata(元数据清单);说的通俗易懂点,就是不用通过引用,仍然可以使用其他层的类。

二、让我们建一个项目来开始操作吧!!!
1、建立一个控制台应用程序,并建立一个类库,类库里添加一个用户类。

 

public class UsersInfo
    {
        public string Name { get; set; }
        public bool Sex { get; set; }
        public void CommonMethod()
        {
            Console.WriteLine("我是普通方法");
        }
        public void ParameterMethod(string name)
        {
            Console.WriteLine("我是带参数方法,我叫"+name);
        }

        public void OverrideMethod(int age)
        {
            Console.WriteLine("我是重载方法,我今年"+age);
        }
        public void OverrideMethod(string name)
        {
            Console.WriteLine("我是重载方法,我叫" + name);
        }
        public void GenericityMethod<T>(T t)
        {
            Console.WriteLine("我是泛型方法方法,类型是"+typeof(T));
        }
        private void PrivateMethod()
        {
            Console.WriteLine("我是私有方法");
        }
        public static void StaticMethod()
        {
            Console.WriteLine("我是静态方法");
        }
    }
2、利用反射获取类库,和类

第一步引用命名空间
第二步,动态加载类库,写要获取类库的绝对路径
第三步,动态获取类型,写类库的名称和类的名称,不需要后缀
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Reflection;//第一步引用命名空间
namespace Reflection
{
    class Program
    {
        static void Main(string[] args)
        {
            {
                //第二步,动态加载类库,写要获取类库的绝对路径
                Assembly assembly= Assembly.LoadFile(@"C:Users炸天张缺缺DesktopReflectionReflection.ModelinDebugReflection.Model.dll");
                //第三步,动态获取类型,写类库的名称和类的名称,不需要后缀
                Type type = assembly.GetType("Reflection.Model.UsersInfo");
                Console.WriteLine(type.Name);
                
            }
        }
    }
}

 

3、利用反射获取属性,和属性类型

遍历类型的属性集合
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Reflection;//第一步引用命名空间
namespace Reflection
{
    class Program
    {
        static void Main(string[] args)
        {
            {
                Console.WriteLine("***********************获取类*****************************");
                //第二步,动态加载类库,写要获取类库的绝对路径
                Assembly assembly= Assembly.LoadFile(@"C:Users炸天张缺缺DesktopReflectionReflection.ModelinDebugReflection.Model.dll");
                //第三步,动态获取类型,写类库的名称和类的名称,不需要后缀
                Type type = assembly.GetType("Reflection.Model.UsersInfo");
                Console.WriteLine(type.Name);
                Console.WriteLine("***********************获取属性*****************************");
                //遍历类型的属性集合
                foreach (var item in type.GetProperties())
                {
                    Console.WriteLine(item.Name+"   "+item.PropertyType);
                }
            }
            
               
            
        }
    }
}

三、获取方法(方法类型比较多,所以单独做个模块来写)
创建一个符合类型的对象
指定要获取的方法名称
创建方法,第一个参数,对象,第二个参数,没有则为空
1、获取普通方法

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Reflection;//第一步引用命名空间
namespace Reflection
{
    class Program
    {
        static void Main(string[] args)
        {
            {
                Console.WriteLine("***********************获取类*****************************");
                //第二步,动态加载类库,写要获取类库的绝对路径
                Assembly assembly= Assembly.LoadFile(@"C:Users炸天张缺缺DesktopReflectionReflection.ModelinDebugReflection.Model.dll");
                //第三步,动态获取类型,写类库的名称和类的名称,不需要后缀
                Type type = assembly.GetType("Reflection.Model.UsersInfo");
                Console.WriteLine(type.Name);
                Console.WriteLine("***********************获取属性*****************************");
                //遍历类型的属性集合
                foreach (var item in type.GetProperties())
                {
                    Console.WriteLine(item.Name+"   "+item.PropertyType);
                }
                Console.WriteLine("***********************普通方法*****************************");
                object oUser = Activator.CreateInstance(type);//创建一个符合类型的对象
                MethodInfo method = type.GetMethod("CommonMethod");//指定要获取的方法名称
                method.Invoke(oUser,null);//创建方法,第一个参数,对象,第二个参数,没有则为空
            }
            
               
            
        }
    }
}

 

2、获取带参数的方法

指定要获取的方法名称
创建方法,第一个参数,对象,第二个参数,是一个object对象数组,写对应的参数类型
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Reflection;//第一步引用命名空间
namespace Reflection
{
    class Program
    {
        static void Main(string[] args)
        {
            {
                Console.WriteLine("***********************获取类*****************************");
                //第二步,动态加载类库,写要获取类库的绝对路径
                Assembly assembly= Assembly.LoadFile(@"C:Users炸天张缺缺DesktopReflectionReflection.ModelinDebugReflection.Model.dll");
                //第三步,动态获取类型,写类库的名称和类的名称,不需要后缀
                Type type = assembly.GetType("Reflection.Model.UsersInfo");
                Console.WriteLine(type.Name);
                Console.WriteLine("***********************获取属性*****************************");
                //遍历类型的属性集合
                foreach (var item in type.GetProperties())
                {
                    Console.WriteLine(item.Name+"   "+item.PropertyType);
                }

                Console.WriteLine("***********************普通方法*****************************");
                object oUser = Activator.CreateInstance(type);//创建一个符合类型的对象
                MethodInfo commonMethod = type.GetMethod("CommonMethod");//指定要获取的方法名称
                commonMethod.Invoke(oUser,null);//创建方法,第一个参数,对象,第二个参数,没有则为空

                Console.WriteLine("***********************带参数的方法*****************************");
                MethodInfo parameterMethod = type.GetMethod("ParameterMethod");//指定要获取的方法名称
                parameterMethod.Invoke(oUser, new object[] { "餐餐"});//创建方法,第一个参数,对象,第二个参数,是一个object对象数组,写对应的参数类型
            }
            
               
            
        }
    }
}

 

3、重载方法

指定要获取的方法名称,和参数类型
创建方法,第一个参数,对象,第二个参数,是一个object对象数组,写对应的参数类型
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Reflection;//第一步引用命名空间
namespace Reflection
{
    class Program
    {
        static void Main(string[] args)
        {
            {
                Console.WriteLine("***********************获取类*****************************");
                //第二步,动态加载类库,写要获取类库的绝对路径
                Assembly assembly= Assembly.LoadFile(@"C:Users炸天张缺缺DesktopReflectionReflection.ModelinDebugReflection.Model.dll");
                //第三步,动态获取类型,写类库的名称和类的名称,不需要后缀
                Type type = assembly.GetType("Reflection.Model.UsersInfo");
                Console.WriteLine(type.Name);
                Console.WriteLine("***********************获取属性*****************************");
                //遍历类型的属性集合
                foreach (var item in type.GetProperties())
                {
                    Console.WriteLine(item.Name+"   "+item.PropertyType);
                }

                Console.WriteLine("***********************普通方法*****************************");
                object oUser = Activator.CreateInstance(type);//创建一个符合类型的对象
                MethodInfo commonMethod = type.GetMethod("CommonMethod");//指定要获取的方法名称
                commonMethod.Invoke(oUser,null);//创建方法,第一个参数,对象,第二个参数,没有则为空

                Console.WriteLine("***********************带参数的方法*****************************");
                MethodInfo parameterMethod = type.GetMethod("ParameterMethod");//指定要获取的方法名称
                parameterMethod.Invoke(oUser, new object[] { "餐餐"});//创建方法,第一个参数,对象,第二个参数,是一个object对象数组,写对应的参数类型

                Console.WriteLine("***********************重载方法int参数*****************************");
                MethodInfo overrideMethodInt = type.GetMethod("OverrideMethod",new Type[] { typeof(int)});//指定要获取的方法名称,和参数类型
                overrideMethodInt.Invoke(oUser, new object[] { 18 });//创建方法,第一个参数,对象,第二个参数,是一个object对象数组,写对应的参数类型

                Console.WriteLine("***********************重载方法string参数*****************************");
                MethodInfo overrideMethodStrint = type.GetMethod("OverrideMethod", new Type[] { typeof(string) });//指定要获取的方法名称,和参数类型
                overrideMethodStrint.Invoke(oUser, new object[] { "餐餐" });//创建方法,第一个参数,对象,第二个参数,是一个object对象数组,写对应的参数类型
            }
            
               
            
        }
    }
}

 

4、泛型方法

指定要获取的方法名称,和泛型参数类型
创建方法,第一个参数,对象,第二个参数,是一个object对象数组,写对应的参数类型
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Reflection;//第一步引用命名空间
namespace Reflection
{
    class Program
    {
        static void Main(string[] args)
        {
            {
                Console.WriteLine("***********************获取类*****************************");
                //第二步,动态加载类库,写要获取类库的绝对路径
                Assembly assembly= Assembly.LoadFile(@"C:Users炸天张缺缺DesktopReflectionReflection.ModelinDebugReflection.Model.dll");
                //第三步,动态获取类型,写类库的名称和类的名称,不需要后缀
                Type type = assembly.GetType("Reflection.Model.UsersInfo");
                Console.WriteLine(type.Name);
                Console.WriteLine("***********************获取属性*****************************");
                //遍历类型的属性集合
                foreach (var item in type.GetProperties())
                {
                    Console.WriteLine(item.Name+"   "+item.PropertyType);
                }

                Console.WriteLine("***********************普通方法*****************************");
                object oUser = Activator.CreateInstance(type);//创建一个符合类型的对象
                MethodInfo commonMethod = type.GetMethod("CommonMethod");//指定要获取的方法名称
                commonMethod.Invoke(oUser,null);//创建方法,第一个参数,对象,第二个参数,没有则为空

                Console.WriteLine("***********************带参数的方法*****************************");
                MethodInfo parameterMethod = type.GetMethod("ParameterMethod");//指定要获取的方法名称
                parameterMethod.Invoke(oUser, new object[] { "餐餐"});//创建方法,第一个参数,对象,第二个参数,是一个object对象数组,写对应的参数类型

                Console.WriteLine("***********************重载方法int参数*****************************");
                MethodInfo overrideMethodInt = type.GetMethod("OverrideMethod",new Type[] { typeof(int)});//指定要获取的方法名称,和参数类型
                overrideMethodInt.Invoke(oUser, new object[] { 18 });//创建方法,第一个参数,对象,第二个参数,是一个object对象数组,写对应的参数类型

                Console.WriteLine("***********************重载方法string参数*****************************");
                MethodInfo overrideMethodStrint = type.GetMethod("OverrideMethod", new Type[] { typeof(string) });//指定要获取的方法名称,和参数类型
                overrideMethodStrint.Invoke(oUser, new object[] { "餐餐" });//创建方法,第一个参数,对象,第二个参数,是一个object对象数组,写对应的参数类型

                Console.WriteLine("***********************泛型方法*****************************");
                MethodInfo genericityMethod = type.GetMethod("GenericityMethod").MakeGenericMethod(new Type[] {typeof(int)});//指定要获取的方法名称,和泛型参数类型
                genericityMethod.Invoke(oUser, new object[] { 123 });//创建方法,第一个参数,对象,第二个参数,是一个object对象数组,写对应的参数类型
            }
            
               
            
        }
    }
}

 

5、私有方法

指定要获取的方法名称,指明是父类的私有方法
创建方法,第一个参数,对象,第二个参数,是一个object对象数组,写对应的参数类型
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Reflection;//第一步引用命名空间
namespace Reflection
{
    class Program
    {
        static void Main(string[] args)
        {
            {
                Console.WriteLine("***********************获取类*****************************");
                //第二步,动态加载类库,写要获取类库的绝对路径
                Assembly assembly= Assembly.LoadFile(@"C:Users炸天张缺缺DesktopReflectionReflection.ModelinDebugReflection.Model.dll");
                //第三步,动态获取类型,写类库的名称和类的名称,不需要后缀
                Type type = assembly.GetType("Reflection.Model.UsersInfo");
                Console.WriteLine(type.Name);
                Console.WriteLine("***********************获取属性*****************************");
                //遍历类型的属性集合
                foreach (var item in type.GetProperties())
                {
                    Console.WriteLine(item.Name+"   "+item.PropertyType);
                }

                Console.WriteLine("***********************普通方法*****************************");
                object oUser = Activator.CreateInstance(type);//创建一个符合类型的对象
                MethodInfo commonMethod = type.GetMethod("CommonMethod");//指定要获取的方法名称
                commonMethod.Invoke(oUser,null);//创建方法,第一个参数,对象,第二个参数,没有则为空

                Console.WriteLine("***********************带参数的方法*****************************");
                MethodInfo parameterMethod = type.GetMethod("ParameterMethod");//指定要获取的方法名称
                parameterMethod.Invoke(oUser, new object[] { "餐餐"});//创建方法,第一个参数,对象,第二个参数,是一个object对象数组,写对应的参数类型

                Console.WriteLine("***********************重载方法int参数*****************************");
                MethodInfo overrideMethodInt = type.GetMethod("OverrideMethod",new Type[] { typeof(int)});//指定要获取的方法名称,和参数类型
                overrideMethodInt.Invoke(oUser, new object[] { 18 });//创建方法,第一个参数,对象,第二个参数,是一个object对象数组,写对应的参数类型

                Console.WriteLine("***********************重载方法string参数*****************************");
                MethodInfo overrideMethodStrint = type.GetMethod("OverrideMethod", new Type[] { typeof(string) });//指定要获取的方法名称,和参数类型
                overrideMethodStrint.Invoke(oUser, new object[] { "餐餐" });//创建方法,第一个参数,对象,第二个参数,是一个object对象数组,写对应的参数类型

                Console.WriteLine("***********************泛型方法*****************************");
                MethodInfo genericityMethod = type.GetMethod("GenericityMethod").MakeGenericMethod(new Type[] {typeof(int)});//指定要获取的方法名称,和泛型参数类型
                genericityMethod.Invoke(oUser, new object[] { 123 });//创建方法,第一个参数,对象,第二个参数,是一个object对象数组,写对应的参数类型

                Console.WriteLine("***********************泛型方法*****************************");
                MethodInfo privateMethod = type.GetMethod("PrivateMethod",BindingFlags.Instance|BindingFlags.NonPublic);//指定要获取的方法名称,指明是父类的私有方法
                privateMethod.Invoke(oUser,null);//创建方法,第一个参数,对象,第二个参数,是一个object对象数组,写对应的参数类型
            }
            
               
            
        }
    }
}

 

6、静态方法

 Console.WriteLine("***********************静态方法*****************************");
                MethodInfo staticMethod = type.GetMethod("StaticMethod");//指定要获取的方法名称
                staticMethod.Invoke(null, null);//不需要实例化,所以第一个可以不写,为空


四、小扩展,反射书写ORM(请原谅我没有注释)
接口

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

namespace NineMonthExam.IDAL
{
    public interface IEFHelpers<T> where T:class
    {
        bool Add(T t);
        bool Remove(int id);
        bool Edit(T t);
        List<T> GetAll();
    }
}

dbhelp类

using NineMonthExam.IDAL;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Configuration;
using System.Data.SqlClient;
using NineMonthExam.Model;

namespace NineMonthExam.DAL
{
    public  class DBHelpers<T> : IEFHelpers<T> where T : BaseModel
    {
        private static  Type type;
        private static string typeName;
        private static string nameStr;
        private static string noIdNameStr;
        private static string sql = "";
        private static StringBuilder addStr = new StringBuilder();
        private static StringBuilder getStr = new StringBuilder();
        private static StringBuilder removeStr = new StringBuilder();
        private static StringBuilder modify = new StringBuilder();
        private static StringBuilder modifyStr = new StringBuilder();
        private static string conStr=ConfigurationManager.ConnectionStrings["conStr"].ConnectionString;
        static DBHelpers()
            {
            type = typeof(T);
            typeName = type.Name;
            nameStr =string.Join(",", type.GetProperties().Select(m=>m.Name));
            noIdNameStr = string.Join(",", type.GetProperties().Where(m=>!m.Name.Equals("Id")).Select(m => m.Name));
            addStr.Append($@"insert into {typeName} ({noIdNameStr}) values ({string.Join(",", type.GetProperties().Where(m => !m.Name.Equals("Id")).Select(m =>$"@{m.Name}"))})");
            getStr.Append($@"select {nameStr} from {typeName}");
            removeStr.Append($@"delete from {typeName}");
            modify.Append($@"update {typeName} set");
            foreach (var item in type.GetProperties().Where(m => !m.Name.Equals("Id")).Select(m => m.Name))
            {
                modify.Append($@" {item}=@{item},");
            }
            string qian = modify.ToString();
            qian = qian.Remove(qian.LastIndexOf(','));
            modifyStr.Append(qian);
            }
        
        public  bool Add(T t)
        {
            SqlParameter[] parameters = type.GetProperties().Where(m => !m.Name.Equals("Id")).Select(m => new SqlParameter($"@{m.Name}", m.GetValue(t) ?? DBNull.Value)).ToArray();
            sql = addStr.ToString();
            using (SqlConnection conn = new SqlConnection(conStr))
            {
                conn.Open();
                SqlCommand com = new SqlCommand(sql,conn);
                com.Parameters.AddRange(parameters);
                return com.ExecuteNonQuery() > 0;
            }
        }

        public  bool Edit(T t)
        {
            SqlParameter[] parameters = type.GetProperties().Select(m => new SqlParameter($"@{m.Name}", m.GetValue(t)??DBNull.Value)).ToArray();
            string edit=$" where Id = @{type.GetProperty("Id").Name}";
            sql = modifyStr.ToString()+ edit;
            using (SqlConnection conn = new SqlConnection(conStr))
            {
                conn.Open();
                SqlCommand com = new SqlCommand(sql, conn);
                com.Parameters.AddRange(parameters);
                return com.ExecuteNonQuery() > 0;
            }
        }
        private T GetT(SqlDataReader sdr)
        {
            T obj = Activator.CreateInstance(type) as T;
            foreach (var item in type.GetProperties())
            {
                if (sdr[item.Name].GetType() != typeof(DBNull))
                {
                    item.SetValue(obj, sdr[item.Name]);
                }
                else
                {
                    item.SetValue(obj, null);

                }
            }
            return obj;
        }
        public  List<T> GetAll()
        {
            sql = getStr.ToString();
            using (SqlConnection conn = new SqlConnection(conStr))
            {
                conn.Open();
                SqlCommand com = new SqlCommand(sql, conn);
                SqlDataReader reader =com.ExecuteReader();
                List<T> list = new List<T>();
                while (reader.Read())
                {
                    list.Add(GetT(reader));
                }
                return list;
            }
        }

        public  bool Remove(int id)
        {
             string del=$" where Id = {id}";
            sql = removeStr.ToString()+del;
            using (SqlConnection conn = new SqlConnection(conStr))
            {
                conn.Open();
                SqlCommand com = new SqlCommand(sql, conn);
                return com.ExecuteNonQuery() > 0;
            }
        }
    }
}

五、结束语:所有的成功都离不开努力,不要用不公平掩饰你不努力的样子
所有的成功都离不开努力,不要用不公平掩饰你不努力的样子

我自是年少,韶华倾负。

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

C#高级特性(反射) 的相关文章

  • 在一个 less 文件中引用另一个 less 文件

    less loader webpack provides an advanced mechanism to resolve files The less loader applies a Less plugin that passes al
  • 给折腾ramdisk的朋友们一点建议

    Ramdisk是什么 xff0c 恐怕不需要我多说大家都知道 至于ramdisk有什么优点 xff0c 百度一下你能看到因为ramsik有着很快的读写速度所以 放临时文件能加快速度 xff0c 装软件可以秒开 等等各种优化的方法 xff0c
  • 网络安全工程师,如何“打怪升级”?

    近年来 xff0c 信息网络安全问题引发了社会各界的广泛关注 xff0c 越来越多的网络安全类人才受到各大公司的青睐 如果你的逻辑分析能力足够强 xff0c 而且同时还有IT领域工作经验 xff0c 那么恭喜你 xff0c 你已经拥有了成为
  • Docker不适合部署数据库的7大原因

    近2年Docker非常的火热 xff0c 各位开发者恨不得把所有的应用 软件都部署在Docker容器中 xff0c 但是您确定也要把数据库也部署的容器中吗 xff1f 这个问题不是子虚乌有 xff0c 因为在网上能够找到很多各种操作手册和视
  • 解决:VMware Workstation 与 Device/Credential Guard 不兼容

    VMware Workstation 与 Device Credential Guard 不兼容 在禁用 Device Credential Guard 后 xff0c 可以运行 VMware Workstation 出现问题的原因 xff
  • IIS部署网站提示handlers节点锁定,HTTP 错误 500

    新安装了一台Win 2016 服务器 xff0c 部署网站提示如下 xff1a 在cmd窗口中执行了 xff1a windir system32 inetsrv appcmd unlock config section system web
  • Debian简单配置squid

    安装squid apt install y squid 修改squid配置文件 xff0c 养成一个好习惯 xff0c 不管修改什么文件之前都先备份原文件 cp etc squid squid conf etc squid squid co
  • 软考--网络工程师(考试形式及重要考点)

  • 部署Kubernetes高可用集群(上)

    一 前置知识点 1 1 生产环境可部署Kubernetes集群的两种方式 目前生产部署Kubernetes集群主要有两种方式 xff1a kubeadm Kubeadm是一个K8s部署工具 xff0c 提供kubeadm init和kube
  • 部署Kubernetes高可用集群(下)

    七 高可用架构 xff08 扩容多Master架构 xff09 Kubernetes作为容器集群系统 xff0c 通过健康检查 43 重启策略实现了Pod故障自我修复能力 xff0c 通过调度算法实现将Pod分布式部署 xff0c 并保持预
  • 记一次 Linux 被入侵全过程

    0x00 背景 周一早上刚到办公室 xff0c 就听到同事说有一台服务器登陆不上了 xff0c 我也没放在心上 xff0c 继续边吃早点 xff0c 边看币价是不是又跌了 不一会运维的同事也到了 xff0c 气喘吁吁的说 xff1a 我们有
  • TCP三次握手、四次挥手过程及原理

    TCP建立连接为什么是三次握手 xff0c 而不是两次或四次 xff1f TCP xff0c 名为传输控制协议 xff0c 是一种可靠的传输层协议 xff0c IP协议号为6 顺便说一句 xff0c 原则上任何数据传输都无法确保绝对可靠 x
  • 详解 Windows自带的MPIO(多路径)

    windows的MPIO 1 在双活系统中 xff0c 常常为客户端配置多路径 xff0c 来保证业务可持续 xff0c 那今天我们来聊聊windows自带的MPIO 2 首先先教大家如何安装windows自带的MPIO xff08 1 x
  • Docker 不适合跑 MySQL 的 N 个原因

    容器的定义 xff1a 容器是为了解决 在切换运行环境时 xff0c 如何保证软件能够正常运行 这一问题 目前 xff0c 容器和 Docker 依旧是技术领域最热门的词语 xff0c 无状态的服务容器化已经是大势所趋 xff0c 同时也带

随机推荐

  • HTTP状态码100、200、300、400、500、600的含义

    HTTP状态码 HTTP Status Code 是当我们访问网页服务器 xff0c 服务器做出相应的状态的3位数的数字代码 主要包括 1xx xff08 消息 xff09 2xx xff08 成功 xff09 3xx xff08 重定向
  • 人败皆因懒,事败皆因傲,家败皆因奢

    古人讲究 修身 齐家 治国 平天下 中国五百年来可以做到此话的人 xff0c 前有王阳明 xff0c 后有曾国藩 曾国藩在仕途看尽了人世兴衰 xff0c 看透了得失成败 xff0c 他曾专门写下家书 xff0c 告诫家族子弟三句话 xff1
  • 为什么 kubernetes 环境要求开启 bridge-nf-call-iptables

    Kubernetes 环境中 xff0c 很多时候都要求节点内核参数开启 bridge nf call iptables sysctl w net bridge bridge nf call iptables 61 1 参考官方文档 Net
  • Debian配置ssh并限制只有指定主机的指定用户可登录

    Debian服务器IP xff1a 192 168 200 129 Debian客户端IP xff1a 192 168 200 131 Debian默认安装了openssh client xff0c 所以服务器端只需要安装openssh s
  • 什么是真正的转运?常见的五种转运方法

    转运在玄学中的含义和大家想有所不同 xff0c 转运在玄学指日月星辰的移动 xff0c 如王充 论衡 说日 xff1a 然而日出上日入下者 xff0c 随天转运 在玄学中还有三元九运之说 xff0c 此皆是星之变化 于天转运是星象改变 xf
  • 微软各系列软件中 MSDN 、 RTM 、 OEM 、 VOL 各版本的含义和区别

    关注系统的朋友会发现 xff0c 微软正式版本的系统往往带有不同的 名号 xff0c 主要分为MSDN版 xff0c RTM版 xff0c OEN版 xff0c 在过去的操作系统中还有VOL版本 xff0c 经常听这几个名词 xff0c 却
  • 部署私有笔记管理系统(为知笔记)

    免费版仅创建5个用户 https hub docker com r wiznote wizserver span class token function docker span run name wz note restart span
  • 树莓派镜像烧录以及使用vscode开发

    树莓派镜像烧录以及使用vscode开发 烧录镜像 1 下载烧录软件 xff08 balenaEtcher下载地址 xff09 2 下载树莓派镜像 下载地址 这里也提供了博主的镜像 下载慢的同学可以看看 下载链接 3 插入sd卡 xff0c
  • gradle指定相应JDK编译

    问题描述 电脑中装有多个jdk版本 xff0c 可能默认的jdk是1 6 xff0c 但是项目中用到了俗称钻石语法的结构就是 lt gt 这玩意 但是由于你装的某些软件必须在1 6版本下才能跑 xff0c 因此你不想更改的你的JAVA HO
  • 无线路由器的连接与设置

    无线路由器的连接与设置 实验目的 掌握无线路由器基础知识掌握无线路由器设置学会使用设备连接无线路由器 实验环境 无线路由器 xff08 FAST迅捷 FW313R xff09 台式机 无线设备 实验内容 1 设置无线路由器上网方式为 固定I
  • 浅谈 PHY 芯片 UTP 接口直连(不使用变压器)的设计

    浅谈 PHY 芯片 UTP 接口直连 xff08 不使用变压器 xff09 的设计 1 背景 xff1a 一个项目 xff0c 需要把IP101GR模块的UTP接口和交换机芯片 xff08 RTL8305NB xff09 的 UTP 接口连
  • 千万不要去外国当程序员

    今天我来讲讲我这样的一个普通程序员是如何从有想法 xff0c 到实施 xff0c 到最后来到欧洲务工的 整个过程很曲折 xff0c 文章有点长 xff0c 大家给点耐心 如果看不下去请直接翻到最后 xff0c 有总结 个人背景 为了避免有人
  • 逻辑思维能力选择题30道

    逻辑思维能力选择题30道 这些题目都是作者选取于网络 xff0c 靠自己动脑做出来的是最棒的 1 有一个有钱人想让你和他玩一个游戏 xff0c 你在纸上写下一句话 xff0c 并作出选择 选择1 xff1a 如果你写的是实话 xff0c 那
  • 单位换算表大全

    长度 1千米 km 61 0 621英里 mile 1米 m 61 3 281英尺 ft 61 1 094码 yd 1丝米 dmm 61 1忽米 cmm 61 1丝 61 0 01毫米 61 0 001厘米 1厘米 cm 61 0 394英
  • Debian配置CA_配置Apache2使用ssl_配置http连接自动跳转到https

    需要使用到两台Debian服务器 xff0c 一台作为ca端 xff0c 一台作为Apache端 ca端IP xff1a 192 168 200 129 Apache端IP xff1a 192 168 200 131 以下是CA端配置 xf
  • 重量(计量单位)英文缩写和转换表

    重量的缩写是W 一 质量单位换算 xff1a 1长吨 xff08 long ton xff09 61 1 016吨 xff08 t xff09 1千克 xff08 kg xff09 61 2 205磅 xff08 lb xff09 1磅 x
  • 逻辑学三大定律是什么?

    逻辑思维三大定律 同一律 xff0c 矛盾律 xff0c 排中律 同一律 xff1a A 是 A 前后思维中 xff0c 概念要同一 白马非马论违反同一律 商家的买一赠一 xff0c 前后两个一不是同一个概念 违反同一律 矛盾律 xff1a
  • 逻辑学三大定律

    1 同一律就是前后提及概念 论题要是同一个 xff0c 不是同一个就是不合逻辑的 看这句话 xff0c 人有几百万年的历史 xff0c 你没有几百万年的历史 xff0c 所以你不是人 xff0c 典型的三段论 xff0c 大前提 xff0c
  • LeetCode:移除元素

    给你一个数组 nums 和一个值 val xff0c 你需要 原地 移除所有数值等于 val 的元素 xff0c 并返回移除后数组的新长度 不要使用额外的数组空间 xff0c 你必须仅使用 O 1 额外空间并 原地 修改输入数组 元素的顺序
  • C#高级特性(反射)

    今天来讲解反射的应用 xff1a 一 反射是什么 xff1f 简诉一下 xff0c 反射就是 Net Framework 的一个帮助类库 xff0c 可以获取并使用metadata xff08 元数据清单 xff09 xff1b 说的通俗易