
C#
taoqick
这个作者很懒,什么都没留下…
展开
-
Python垃圾回收(GC)三层心法,你了解到第几层?
垃圾回收机制应该是面试最常问的问题了,那么Python中的垃圾回收机制(Garbage Collection)是怎么解决的呢?我记得每一本python入门的书籍都会说python中请不要担心内存泄漏这个 问题,那么这个背后又是什么原理,今天就来818。Python中的GC算法分为下三点:引用计数/标记-清除/分代回收·引用计数(主要)刚开始学习Python的时候总是会有人告诉你,万...转载 2019-12-10 17:06:19 · 217 阅读 · 0 评论 -
C# Dump all fields for a static class [Debug]
List all fields: private static void PrintAllFields(Type t) { FieldInfo[] fields = t.GetFields(BindingFlags.Static | BindingFlags.Public | BindingFlags.GetField | Binding...原创 2019-12-10 16:57:46 · 103 阅读 · 0 评论 -
c# 非async方法调用async方法
在C#中,强烈不建议非async方法调用async方法,建议一路async/await下去。如果一定要非async方法调用async方法,建议按照以下的优先级使用:1. Task.Run(...).Result, 这种方式是新起了一个Task放在线程池中,参考:https://devblogs.microsoft.com/pfxteam/should-i-expose-synchrono...原创 2019-04-18 17:33:45 · 3701 阅读 · 0 评论 -
轻松学,浅析依赖倒置(DIP)、控制反转(IOC)和依赖注入(DI)
写这篇文章的原因是这两天在编写关于 Dagger2 主题的博文时,花了大量的精力来解释依赖注入这个概念。后来想一下,这些在面向对象开发过程中与依赖相关的诸多术语和概念实际情况下非常的抽象,因此独立成文也有就一定的意义,旨在帮助初学者快速地对这些概念有一个大致的印象,然后通过一些实例来领悟它们之中的内在奥秘。什么是依赖(Dependency)?依赖是一种关系,通俗来讲就是一种需要。程序...转载 2019-03-09 18:32:14 · 376 阅读 · 0 评论 -
c# interface 和 abstract class的区别
Difference Between C# Interface vs Abstract ClassC# is anobject-oriented programming languagethat is used in .Net framework to develop the desktop applications and web applications as well. It was...转载 2019-03-08 19:43:42 · 750 阅读 · 0 评论 -
C# Task.WhenAll Parallel 2 [Debug]
Thread.Sleep and non-Async method will block the threadawait Task.Delay or await Async method will delay the task, but won’t block the thread. The usage of thread will be handed over to other tasks.原创 2016-12-27 20:29:27 · 1335 阅读 · 0 评论 -
C# Serialize and Deserialize XML string [Debug]
Here is an example:using System;using System.IO;using System.Xml;using System.Xml.Serialization;namespace XMLTest1{ public class Test { public string value1 { get; set; } ...原创 2017-10-20 17:17:57 · 399 阅读 · 0 评论 -
C#中重写(override)和覆盖(new)的区别
From http://www.cnblogs.com/xumingxiang/archive/2012/04/14/override_new.html重写用关键字 virtual 修饰的方法,叫虚方法。可以在子类中用override 声明同名的方法,这叫“重写”。相应的没有用virtual修饰的方法,我们叫它实方法。重写会改变父类方法的功能。看下面演示代码:转载 2017-10-10 11:23:17 · 396 阅读 · 0 评论 -
c# task run in background
1. Task.Run will start to run in background2. Don't use breakpoint to debug, or all tasks will be interupted. using System;using System.Collections.Generic;using System.Linq;using System.Thread原创 2017-02-23 15:36:41 · 1610 阅读 · 0 评论 -
C# Task.WhenAll Parallel 1 [Debug]
Several Points:tasks.Add(), use variable capture to "pass in" parameters. If you change the value of variables of a task (for example a iterator in a for loop) it will also change the value insid...原创 2016-12-25 16:01:37 · 1827 阅读 · 0 评论 -
Assembly.Get***Assembly的区别
GetEntryAssembly获取的是当前应用程序第一个启动的程序,一般就是xxx.exe文件。 GetExecutingAssembly获取的是当前执行的方法所在的程序文件,可能是.exe,也可能是当前方法所在的.dll文件。 如一个程序MyApp.exe,在程序中引用了MyDll.dll类库,而在MyDll.dll中有一个MyInfo方法,MyInfo调用了MyDll2.dll中转载 2016-03-09 19:23:09 · 824 阅读 · 0 评论 -
C# String与string的区别 以及 C# Swap string
最近,正在简单地学习C#的一些知识。C#是区分大小写的,但是我却发现C#中同时存在String与string,于是我很困惑,于是我上网搜索了一下,于是我了解了一些小知识。MSDN中对string的说明:string is an alias for String in the .NET Framework。string是String的别名而已,string是c#中的类,Str转载 2015-08-17 15:15:24 · 1259 阅读 · 0 评论