2011-04-09 71 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