이 버그를 찾는 반나절. 세 번째 경우 예기치 않은 결과가 발생하는 이유는 무엇입니까?
// case 1
string value1 = "a" + "a" + "A";
byte[] asciiBytes1 = Encoding.ASCII.GetBytes(value1); // expected: 97 - 97 - 65
Console.WriteLine(string.Join(" - ", asciiBytes1)); // result: 97 - 97 - 65
// case 2
string value21 = 'a' + "A";
byte[] asciiBytes21 = Encoding.ASCII.GetBytes(value21); // expected: 97 - 65
Console.WriteLine(string.Join(" - ", asciiBytes21)); // result: 97 - 65
// case 3
string value22 = 'a' + 'a' + "A";
byte[] asciiBytes22 = Encoding.ASCII.GetBytes(value22); // expected: 97 - 97 - 65
Console.WriteLine(string.Join(" - ", asciiBytes22)); // result: 49 - 57 - 52 - 65
문자와 문자열을 혼합하고 있습니다. 이 : 'a'+ 'a'는 ascii char 값의 정수 추가를 생성합니다.
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다