zoukankan      html  css  js  c++  java
  • 【干货】干货篇

    1.有空格的字符串 拆成数组

     string str = System.Text.RegularExpressions.Regex.Replace(headProducts, @"s+", ",");
     string[] Products= str.Split(',');

     2.生成日志

            public void Log(string message)
            {
                string LogPath = @"C:Log";
                if (!Directory.Exists(LogPath))
                {
                    Directory.CreateDirectory(LogPath);
                }
                string filePath = LogPath + "_wxp.log";
                using (FileStream stream = File.Open(filePath, FileMode.Append, FileAccess.Write, FileShare.Write))
                {
                    using (StreamWriter sw = new StreamWriter(stream))
                    {
                        sw.WriteLine();
                        sw.WriteLine(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "-----------------------------------");
                        sw.WriteLine(message);
                        sw.WriteLine();
                        sw.Flush();
                    }
                }
            }

     3.Ioc DI

        IOC:没有用IOC之前是直接new实例来赋值,使用IOC之后是通过在运行的时候根据配置来实例化具体对象,这个控制权由内部转到外部的过程就可以理解为IOC(控制反转)
    
        DI:由IoC容器在运行期间,动态地将某种依赖关系注入到对象之中
    services
    AddTransient 每次都重新创建一个实例。 AddSingleton 创建一个单例,以后每次调用的时候都返回该单例对象。 AddScoped 在当前作用域内,不管调用多少次,都是一个实例,换了作用域就会再次创建实例,类似于特定作用内的单例。

     4.winform跨线程

        Control.CheckForIllegalCrossThreadCalls = false

     5.Mongo export and import

    .mongoimport -d [database] -c [table] --type csv --headerline --file [filename].dat
    
    .mongoexport -d [database] -c [table] --csv -f [colum] -o [filename].dat   
  • 相关阅读:
    ASP.net中页面事件的先后顺序
    我回来了
    ASP.NET中添加引用不能显示
    VS2008中MVC无法打开项目文件,此安装不支持该项目类型
    windows2003 IIS错误
    C#中使用TimeSpan计算两个时间的差值
    javascript做在翻译
    GridView导出EXCEL
    用资源管理器限制大数据量查询
    linux单机配置DG过程记录
  • 原文地址:https://www.cnblogs.com/xuxml/p/10418533.html
Copyright © 2011-2022 走看看