vb.net - 如何在 vb.net 中将对象转换为字符串数组?
问题描述
在我的代码中,我将字符串数组作为对象存储在字典中。因为<string,object>
当我从 dict 检索值时,该字典是一种类型,就像dict.item("string")
它只给了我一个对象(显然)但我需要一个字符串数组。现在怎么拿回来?
我在这里看到了很多问题,它们就像对象数组到字符串数组,有些和我的一样,但是在 java 中,我需要 Vb.net 中的一行代码
编辑:将字符串数组存储到字典中的代码
string_array[2] = {username, new system.Net.NetworkCredential(string.Empty, password).Password} ; out_Config(row("Name").ToString) = string_array
解决方案
如果您无法修改字典以保存字符串数组而不是对象(因为它还保存其他类型),那么您可以将值从对象转换回字符串数组:
Dim dict As New Dictionary(Of String, Object)
dict.Add("item", New String() {"1", "2"})
Dim stringArray = CType(dict("item"), String())
推荐阅读
- python - 提取重复的 JSON 标签
- python - 如何在 Jupyter 笔记本中将视频文件的帧显示为 gif 而无需写入文件
- sql - SQL查询 - 填充缺失值
- python - EarlyStopping 是否采用最后一个时期或最后最好成绩的模型?
- php - 在 Woocommerce 管理订单页面中更改文本“计费”和“运输”
- dll - 在 Inno Setup 中加载具有依赖项的 DLL 在卸载程序中失败并显示“无法导入 DLL”,但在安装程序中有效
- sql - 获取最新的 ModifiedDate 加入多个表
- amazon-s3 - 云桶病毒安全
- python - df.to_sql 出现错误:将数据类型 nvarchar 转换为浮点数时出错
- flutter - 如何解决“不正确使用 ParentDataWidget”。在 main.dart