BitConverter.TryWrtieBytes 부분이 잘 이해가지 않습니다.
미해결
[C#과 유니티로 만드는 MMORPG 게임 개발 시리즈] Part4: 게임 서버
ServerSession 클래스의 Write 함수의 일부입니다. // 최종적으로 패킷의 크기를 할당하기 위한 공간 확보 count += sizeof(ushort); success &= BitConverter.TryWriteBytes(s.Slice(count, s.Length - count), this.packetId); count += sizeof(ushort); success &= BitConverter.TryWriteBytes(s.Slice(count, s.Length - count), this.playerId); count += sizeof(long); BitConverter.TryWriteBytes(s.Slice(count, s.Length - count), this.packetId); 와 같이 스팬을 자를 때 왜 s.Length - count로 count 부터 남은 공간을 전부 자르는 건가요? ushort 크기를 사용할 것이기에 s.Slice(count, sizeof(ushort))로 사용할 공간만 잘라서 사용하는 것이 더 효율적인 것이 아닌가요? +추가 이 이유가 강의에서 말씀해주셨던 누군가가 이상한 값을 할당해 정확한 크기가 전달되지 않을 가능성이 있어서 남은 공간을 모두 확인하려는 의도일까요??
- C#
- unity
- 네트워크
- bitconverter
- write





