本文介绍了在数组中输入字节的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 您好, 我想检索存储在file.dat中的数据并填充数组中的每个字节。 在这个file.dat文件中有数字。在每个数字之前都有一个数据。 例如 $ b $bè(26 +# 1280 (555( - 1281 所以我想将数据存储在我的数组中这样 myarray [0] =0 myarray [1] = 8 myarray [2] =2 myarray [3] =1 myarray [4] = myarray [5] =# myarray [6] =+ ... .... i使用visaul studio 2008智能设备c# i不知道,请帮助 谢谢 我尝试过: 您好, 我想检索存储在file.dat中的数据并填充数组中的每个字节。 在这个file.dat文件中是数字。在每个数字之前有一个数据。 例如 $ b $bè(26 +# 1280 (555( - 1281) 所以我想将数据存储在我的数组中这样 myarray [0] =0 myarray [1] =8 myarray [2] =2 myarray [3] =1 myarray [4] = myarray [5] =# myarray [6] =+ ... .... 解决方案 最简单的方法是从正则表达式开始。假设数据始终采用以下形式: < prefix bit>< space><您想要的数字> 然后第一个任务是将它们作为单独的代码提取: public static 正则表达式regex = 新正则表达式( [^ \\s] + \\s\\d +(\\s | ), RegexOptions.Multiline | RegexOptions.Compiled ); 应该这样做。 然后在文件内容上使用正则表达式: string dataFromFile = File.ReadAllText(path); MatchCollection matches = regex.Matches(dataFromFile); if (ms.Count > 0 ) { foreach (匹配m 匹配) { string code = m.Value.Trim(); char [] reversed = code.Reverse()。ToArray(); ... } } Hello,I would like to retrieve data who is stored in file.dat and fill every byte in a array.In this file.dat file there are numbers. before each number there is a data.for exampleè(26+# 1280 (555(- 1281so i want to store the data in my array like thismyarray[0]="0"myarray[1]="8"myarray[2]="2"myarray[3]="1"myarray[4]=" "myarray[5]="#"myarray[6]="+".......i work with visaul studio 2008 smart device c#i have no idea, please helpeThanksWhat I have tried:Hello,I would like to retrieve data who is stored in file.dat and fill every byte in a array.In this file.dat file there are numbers. before each number there is a data.for exampleè(26+# 1280 (555(- 1281so i want to store the data in my array like thismyarray[0]="0"myarray[1]="8"myarray[2]="2"myarray[3]="1"myarray[4]=" "myarray[5]="#"myarray[6]="+"....... 解决方案 The easiest way is to start with a Regex. Assuming that the data is always in the form<prefix bit><space><number you want>Then the first task is to extract them as separate "codes":public static Regex regex = new Regex( "[^\\s]+\\s\\d+(\\s|)", RegexOptions.Multiline | RegexOptions.Compiled );Should do it.Then use the regex on the file content:string dataFromFile = File.ReadAllText(path);MatchCollection matches = regex.Matches(dataFromFile);if (ms.Count > 0) { foreach (Match m in matches) { string code = m.Value.Trim(); char[] reversed = code.Reverse().ToArray(); ... } } 这篇关于在数组中输入字节的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云! 08-24 06:45