当前位置: 首页 > news >正文

做婚恋网站多少钱百度的首页

做婚恋网站多少钱,百度的首页,网站案例分析湖南,seo岗位培训方法一:使用List 使用List可以很容易地在末尾添加字节,然后如果需要,可以将其转换回byte[]。 using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Lin…

方法一:使用List

使用List可以很容易地在末尾添加字节,然后如果需要,可以将其转换回byte[]。

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Threading;namespace WindowsFormsApplication1
{public partial class Form1 : Form{public Form1(){InitializeComponent();}List<byte> byteList = new List<byte>();private void byteAddFun(){byteList.Clear();// 添加字节  byteList.Add(0x01);byteList.Add(0x02);byteList.Add(0x03);// 如果需要,转换为byte[]  byte[] byteArray = byteList.ToArray();foreach (byte b in byteArray)textBox1.Text += b.ToString("X2") + " ";// 添加字节  byteList.Add(0x05);byteList.Add(0x06);byteList.Add(0x07);// 如果需要,转换为byte[]  byte[] byteArray2 = byteList.ToArray();foreach (byte b in byteArray2)textBox1.Text += b.ToString("X2") + " ";}private void byteAddFun2(){byteList.Clear();// 添加字节  byteList.Add(0x05);byteList.Add(0x06);byteList.Add(0x07);// 如果需要,转换为byte[]  byte[] byteArray2 = byteList.ToArray();foreach (byte b in byteArray2)textBox1.Text += b.ToString("X2") + " ";}private void button1_Click(object sender, EventArgs e){textBox1.Text = null;byteAddFun();}private void button2_Click(object sender, EventArgs e){textBox1.Text = null;byteAddFun2();}}
}

在这里插入图片描述
在这里插入图片描述

方法二:使用Array.Resize或新的Array.Copy

如果已经有一个byte[]并希望添加更多字节,则可以使用Array.Resize来重新调整数组的大小,但请注意这可能会导致性能问题,因为每次添加字节时都需要重新分配整个数组。
或者也可以创建一个新的更大的数组,然后使用Array.Copy将旧数组的内容复制到新数组中,并在新数组的末尾添加新的字节。

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Threading;namespace WindowsFormsApplication1
{public partial class Form1 : Form{public Form1(){InitializeComponent();}private void byteAddFun(){byte[] byteArray = new byte[] { 0x01, 0x02, 0x03 };// 假设我们要添加一个新的字节 0x04  byte newByte = 0x04;// 创建一个新的更大的数组  byte[] newByteArray = new byte[byteArray.Length + 1];// 复制旧数组的内容到新数组  Array.Copy(byteArray, 0, newByteArray, 0, byteArray.Length);// 在新数组的末尾添加新的字节  newByteArray[newByteArray.Length - 1] = newByte;// 现在 newByteArray 包含 [0x01, 0x02, 0x03, 0x04]foreach (byte b in newByteArray)textBox1.Text += b.ToString("X2") + " ";}private void button1_Click(object sender, EventArgs e){textBox1.Text = null;byteAddFun();}private void button2_Click(object sender, EventArgs e){textBox1.Text = null;byteAddFun();}}
}

三、注意

如果需要频繁地向数组添加字节,并且事先不知道最终的大小,那么使用List通常是一个更好的选择,因为它可以自动处理重新分配的问题,并且通常具有更好的性能。但是,如果已经知道最终的大小,或者只是偶尔需要添加字节,那么使用Array.Resize或Array.Copy可能是可以接受的。

http://www.mmbaike.com/news/94668.html

相关文章:

  • 如何自己建设电影网站免费网站seo优化
  • 南京网站开发南京乐识强培训网站模板
  • 施工企业成本核算方法360优化大师最新版
  • ecs 网站设计营销和销售的区别
  • 小学文化学网站开发接外包项目的网站
  • 网站建设教程搭建动态网站建设
  • 乌鲁木齐网站开发市场调研分析报告模板
  • 做网站的公司不会设计快速提高排名
  • wordpress建站腾讯云温州百度推广公司电话
  • 用jsp做的可运行的网站c++培训班学费一般多少
  • 黑龙江省建设安全教育信息网扬州网络优化推广
  • 网站宣传方案站内seo内容优化包括
  • 佛山p2p网站建设百度地图网页版
  • 怎么做云购网站新冠咳嗽怎么办
  • 北京最新疫情防控政策杭州seo营销公司
  • 商贸有限公司怎么注销seo概念
  • 做网站用什么框架优化软件下载
  • 洛阳西工区做网站哪家好腾讯广告投放平台官网
  • 网站建设年终总结怎么写谷歌seo排名
  • 免费网站建设阿里云seo优化网站查询
  • 好用WordPress产品展示主题搜索引擎营销优化诊断训练
  • 做鞋子有什么好网站好百度下载软件
  • 做k线图网站百度广告价格
  • 如何安全的做黄色网站网络营销的营销策略
  • wordpress怎么调用多语言免费seo诊断
  • 做网站怎么存放视频网站建设报价明细表
  • 做360pc网站排名首页外贸独立站怎么建站
  • 做网站版权怎么写推销
  • 怎么开个人网站营销型网站制作成都
  • 网站服务器不稳定seo排名优化网站