Skip to content

Instantly share code, notes, and snippets.

public class Target
{
private delegate int MyDelegate();
public int MyMethod(int original)
{
MyDelegate mydelegate = new DelegateSource().DelegateOne;
var mod = mydelegate();
return original % mod;
}
}
//第二版
public class Target
{
public delegate int MyDelegate();
private MyDelegate _myDelegate;
public MyDelegate GetsMod
{
get
{
//第三版
public class Target
{
public delegate int MyDelegate();
private MyDelegate _myDelegate = new DelegateSource().DelegateOne;
public int MyMethod(int original)
{
var mod = _myDelegate();
return original % mod;
//v8
protected void btnCalculate_Click(object sender, EventArgs e)
{
//若頁面通過驗證
if (this.IsValid)
{
//取得畫面資料
var product = this.GetProduct();
ILogistics logistics = FactoryRepository.GetILogistics(this.drpCompany.SelectedValue, product);
// Reference type (because of 'class')
class SomeRef { public Int32 x; }
// Value type (because of 'struct')
struct SomeVal { public Int32 x; }
static void ValueTypeDemo() {
SomeRef r1 = new SomeRef(); // Allocated in heap
SomeVal v1 = new SomeVal(); // Allocated on stack
Chapter 5 Primitive, Reference, and Value Types 123
r1.x = 5; // Pointer dereference
v1.x = 5; // Changed on stack
第一章 帝國的餘輝-AT&T
第二章 藍色巨人-IBM 公司
第三章 「水果」公司的復興-賈伯斯和蘋果公司
第四章 電腦產業的生態鏈
第五章 奔騰的心-英特爾公司
第六章 IT 領域的羅馬帝國-微軟公司
第七章 網際網路的金門大橋-思科公司
第八章 英名不朽-楊致遠、費羅和雅虎公司
第九章 矽谷的見證人-惠普公司
第十章 沒落的貴族-摩托羅拉公司
static void Main(string[] args)
{
string[] ten = new string[] { "甲", "乙", "丙", "丁", "戊", "己", "庚", "辛", "壬", "癸" };
string[] di = new string[] { "子", "丑", "寅", "卯", "辰", "巳", "午", "未", "申", "酉", "戌", "亥" };
Recursive(ten, di, 0, 0);
}
static void Recursive(string[] ten, string[] di, int tenPointer, int diPointer)
function doIframe(){
o = document.getElementsByTagName('iframe');
for(i=0;i<o.length;i++){
if (/\bautoHeight\b/.test(o[i].className)){
setHeight(o[i]);
addEvent(o[i],'load', doIframe);
}
}
}
@hatelove
hatelove / UnitTest.cs
Created March 23, 2012 05:57
20120323 ASP.NET: Refactoring to Patterns sample
//v7
/// <summary>
///GetILogistics 的測試
///</summary>
[TestMethod()]
public void GetILogisticsTest_GetBlackCat()
{
//arrange
string p = "1";
@hatelove
hatelove / gist:2184839
Created March 24, 2012 16:25
dev在經歷單元測試的各個階段
1.測試程式看起來好難,好花時間
2.測試程式真容易寫(3A)
3.一次要寫兩份好麻煩
4.Production code真難測
5.程式寫的真爛,思考怎麼寫出可測試的程式
6.看到測試程式紅燈的快感
7.需求異動,一次要改兩份
8.丟掉重寫一份測試程式
9.Ctrl+R, Ctrl+T 的頻率 = F5,Ctrl+R, A的頻率 = Ctrl+S
10.寫程式自然具可測試性