標籤:建議28:理解延遲求值和主動求值之間的區別要理解延遲求值(lazy evaluation)和主動求值(eager evaluation),先看個例子: List<int> list = new List<int>() { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }; var temp1 = from c in list where c > 5 select c; var
標籤:建議45:為泛型型別參數指定逆變逆變是指方法的參數可以是委託或者泛型介面的參數類型的基類。FCL4.0中支援逆變的常用委託有:Func<int T,out TResult>Predicate<in T>常用委託有:IComparer<in T>下面例子示範了泛型型別參數指定逆變所帶來的好處: class Program { static void Main() { Programmer p =
標籤:建議34:為泛型參數設定約束“約束”這個詞可能會引起歧義,有些人肯能認為對泛型參數設定約束是限制參數的使用,實際情況正好相反。沒有“約束”的泛型參數作用很有限,倒是“約束”讓泛型參數具有了更多的行為和屬性。查看下面代碼,我們會發現參數t1或參數t2僅僅具有object的屬性和行為,所以幾乎不能再方法中對它們進行任何操作: class SalaryComputer { public int
標籤:acm演算法A. Electionstime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputThe country of Byalechinsk is running elections involving n candidates. The country consists of m cities. We know how many
標籤:最近搞壞了ubuntu,大半夜裝好公司的電腦-limint系統,第二天早晨編譯 ./configure出錯configure: error: C compiler cannot create executables很是無語呀,找了很多解決辦法:1,Having a compiler (like gcc) is not enough to compile C programs, you also need a C library. If it is missing, you will
標籤:Will It Stop?Available memory: 64 MB. Byteasar was wandering around the library of the University of Warsaw and at one of its facades he noticed a piece of a program with an inscription “Will it stop?”. The question seemed