string转short
时间: 2023-09-01 16:12:27 浏览: 128
要将字符串转换为short类型,可以使用以下方法:
```c
public short[] stringToShort(String inString, out short[] outShort) {
if (inString.Length % 2 == 1) {
inString = inString + " ";
}
char[] bufChar = inString.ToCharArray();
byte[] oufByte = Encoding.Default.GetBytes(bufChar);
byte[] bufByte = new byte = oufByte[i];
bufByte = oufByte[i + 1];
outShort[j = BitConverter.ToInt16(bufByte, 0);
}
return outShort;
}
private void button1_Click(object sender, EventArgs e) {
short[] arr2 = new short<span class="em">1</span><span class="em">2</span>
#### 引用[.reference_title]
- *1* [C# STRING TO SHORT[]方法](https://blog.csdn.net/weixin_43120117/article/details/103005937)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"]
- *2* [C++定义函数模板代码,可以编写通用的函数来处理多种类型的容器](https://download.csdn.net/download/weixin_44609920/88222478)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"]
[ .reference_list ]
阅读全文