2011-04-09 70 views

回答

3
private static int cn = 0; 
public static int C(int i, string s) 
{ 
    return s[i]^(cn | 1)^(((cn++ & 1) == 1) ? i : 0)^0x55; 
} 
+0

感謝您的這一點......作品像魅力! d(「,) – SolidSnake 2011-04-09 22:08:01

+0

這個函數做什麼? – kobe 2011-04-09 22:21:13

+0

@kobe - 它做的東西:o)..我用它來解決一個難題。 – SolidSnake 2011-04-09 23:33:01

1
private static int cn = 0; 
public static int C(int i, string s) 
{ 
    return ((byte)s[i])^(cn|1)^((cn++ & 1) != 0 ? i:0)^0x55; 
} 

這是在假設的功能是進入一類的靜態函數寫的,所以你會這樣稱呼它:

MessageBox.Show(MyType.C(0, "test")); //Output: 32 

如果您刪除static關鍵字,你可以稱它爲一個實例方法:

MyType something = new MyType(); 
MessageBox.Show(something.C(0, "test"); //Output: 32