' character in c#

  • Thread starter Thread starter Dakkar
  • Start date Start date
D

Dakkar

when i write something like this

char[] arr = {'a','b','''}


its giving the
Error 2 Empty character literal
error how can i add the ' character to an
char array
 
You can escape the ' and " characters like this:

char[] arr = {'a','b','\''};

--Richard
 
Escape it
e.g. char[] arr = {'a','b','\''}

Ciaran

Dakkar said:
when i write something like this

char[] arr = {'a','b','''}


its giving the
Error 2 Empty character literal
error how can i add the ' character to an
char array
 
I'm afraid, it's just a bug in your code !
You must replace "j<11" by "j<sifre.Length".

Lionel.

Dakkar said:
I have one more question
i made a code like this for changing characters in a string to another
charahcter


public String passreturn(String username)
{
Char[] sifre = { 'a', 'b', 'c', 'd', 'e', 'f',
'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'r', 's', 't', 'u',
'v', 'w', 'x', 'y', 'z' };
Char[] crypt = { 'n', 'o', 'p', 'q', 'r', 's',
't', 'u', 'v', 'w', 'x', 'y', 'z', '{', '|', '}', '', '!',
'\"', '#', '$', '%', '&', '\'', '('};
int i=0;
String cryptedpw="";
for (int j = 0; j < 11;j++ )
{
if (sifre[j] == username &&
i <= username.Length-1)
{
cryptedpw = cryptedpw + crypt[j];
i++;
j = -1;
}

}
return (cryptedpw);
}


but the characters after z like % & ' is not proccesing
for example when i send the word dakka
its returning this [b:881676c071]qnnxn[/b:881676c071] but when i send
the word [b:881676c071]dakkar[/b:881676c071] its still returning
[b:881676c071]qnxxn[/b:881676c071] instead
[b:881676c071]qnxxn[/b:881676c071]
How can i fix this are there any ascii protection in c#
 
Back
Top