A에는 다음과 같은 16 진수 텍스트 파일이 있습니다.
FE 99 77 88
int 배열로 변환하고 싶습니다. 그래서 그것을 완료하는 방법? C # 콘솔을 사용하고 있습니다. 그리고 방금 프로그래밍을 시작했습니다. Thanhks 당신!
아래 코드를 시도하십시오. 나는 그것을 매우 간단하고 명확하게 만들었습니다.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
namespace ConsoleApplication1
{
class Program
{
const string FILENAME = @"c:\temp\test.txt";
static void Main(string[] args)
{
StreamReader reader = new StreamReader(FILENAME);
string inputLine = "";
List<byte> data = new List<byte>();
while ((inputLine = reader.ReadLine()) != null)
{
string[] splitArray = inputLine.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).ToArray();
foreach(string hexNumberStr in splitArray)
{
byte hexNumber = byte.Parse(hexNumberStr, System.Globalization.NumberStyles.HexNumber);
data.Add(hexNumber);
}
}
reader.Close();
}
}
}
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다