implement some algorithm by C#