Skip to content

Instantly share code, notes, and snippets.

internal class CompoundComparer<T> : IComparer<T>
{
private readonly IComparer<T> primary;
private readonly IComparer<T> secondary;
internal CompoundComparer(IComparer<T> primary,
IComparer<T> secondary)
{
this.primary = primary;
this.secondary = secondary;
@hatelove
hatelove / gist:5932379
Last active December 19, 2015 09:19
public static IEnumerable<TResult> SelectManay<TSource, TCollection, TResult>(this IEnumerable<TSource> source, Func<TSource, int, IEnumerable<TCollection>> collectionSelector, Func<TSource, TCollection, TResult> resultSelector ) 的基本架構
public static IEnumerable<TResult> SelectManay<TSource, TCollection, TResult>(this IEnumerable<TSource> source,
Func<TSource, int, IEnumerable<TCollection>> collectionSelector,
Func<TSource, TCollection, TResult> resultSelector
)
{
var index = 0;
foreach (TSource sourceItem in source)
{
IEnumerable<TCollection> collection = collectionSelector(sourceItem, index);
public class GrandFather
{
[StringLength(5, MinimumLength = 3)]
public string Name { get; set; }
[NestedValidation]
public List<Father> Fathers { get; set; }
}
public class Father
public abstract class AbstractBoxOfFruit<TFruit> where TFruit : Fruit
{
public abstract void Add(TFruit fruit);
}
public class BoxOfApple : AbstractBoxOfFruit<Apple>
{
public override void Add(Apple fruit)
{
// 要加入參考system.componentmodel.dataannotations.dll
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.ComponentModel.DataAnnotations;
using System.Reflection;
namespace ModelValidate
我們家在徵 Sr. .NET developer,職缺資訊:
http://www.104.com.tw/jobbank/custjob/index.php?r=job&j=4c70426e4c463f5631323a63383e36620383a436d565c3e212121211e382b2625381j99&jobsource=cj2008
有興趣的朋友歡迎內洽,也請準備好 resume(中英文各一份) , 一切順利的話,我可以幫您直接轉交履歷,以方便後續安排 interview 流程。
也順便 highlight 幾個重點:
1. OOD/OOP (雖然老生常談了,不過這一點對我們來說還是很重要)
2. 版本控管使用經驗(必備), CI, Unit testing(automation) 經驗佳
3. 主動積極學習技術的熱忱
4. 團隊合作經驗
Hi folks,
這邊有一篇王建興前輩針對區域變數命名長度的見解,講的挺清楚的,雖與我們現行不盡相同,但看一下對大家肯定會有幫助。
請參考: http://www.ithome.com.tw/itadm/article.php?c=68698
整篇文章最重要的就是: 範圍的大小,影響命名的講究程度
一般來說,如果您可以做到以下條件同時成立,命名不用太長沒關係:
1. 一個function的內容,或是該變數生命週期,不到一頁的長度
這兩天跟一些前輩在討論,如果只是要判斷集合有沒有資料,到底是要用Count() > 0 比較好,還是用 Any() 比較好。
而在一些資料結構上,如List<T>,Count() 跟Count的差異到底在哪。
這邊給個Count()擴充方法的程式碼:
https://gist.github.com/regionbbs/17c2d551479171c48eb8
大家應該都知道,IEnumerable其實就是給foreach用的串列集合而已,除了給foreach用的以外,上面並沒有甚麼其他多餘的屬性或方法。
而Count這個屬性在一堆集合裡面可以用,是因為這堆集合都有實作了ICollection or ICollection<T>,因此有Count可以用。
歸納一下結論:
@hatelove
hatelove / gist:5334943
Created April 8, 2013 07:38
LINQ training session 3 - Generic homework
using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using LinqSession3_GenericSample;
using System.Text;
namespace UnitTestLinqSession3
{
[TestClass]
public class UnitTest1
{
public class SpecialDate
{
public DateTime GetThreeMonthLater(DateTime original)
{
//msdn reference: http://msdn.microsoft.com/zh-tw/library/system.datetime.addmonths.aspx
//AddMonths 方法會將閏年和月份天數列入考量以計算結果的月份和日期,然後調整產生之 DateTime 物件的日期部分。
//如果產生的日期在產生的月份中不是有效的日期,則會使用產生之月份的最後一個有效日期。
//例如 3 月 31 日 + 1 個月 = 4 月 30 日。產生之 DateTime 物件的當天時間部分仍然與這個執行個體相同。
var result = original.AddMonths(3);
return result;