1

since i'm poor with javascript I would like someone to convert this small function to C# code for me..

var cn = 0;
function C(i,s)
{ 
   return s.charCodeAt(i) ^ (cn|1) ^ ((cn++ & 1)?i:0) ^ 0x55 
}

I would really appreciate your help. thanks in advance :)

2 Answers 2

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;
}
Sign up to request clarification or add additional context in comments.

1 Comment

what does this fucntion does??
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;
}

That's written with the assumption that the function is going into a class as a static function, so you would call it like this:

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

If you remove the static keyword, you can call it as an instance method:

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.