c# - 在 C# 中读取数组列

标签 c# arrays npgsql

我的代码是这样的,但它给出了一个错误:

//array_field is an array of double values 
NpgsqlCommand Command = new NpgsqlCommand("SELECT array_fied from atable"); 
NpgsqlDataReader dr = Command.ExecuteReader(); 
while (dr.Read()) 
{
    double[] rrr = dr.GetDouble(dr.GetOrdinal("array_field")); 
}

错误信息是:无法将 'double' 隐式转换为 'double[]'。我也尝试了其他变体,但也不起作用。

感谢朱迪特的帮助

最佳答案

Double[] rrr = dr["array_field"] as Double[];

关于c# - 在 C# 中读取数组列,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18654994/

相关文章:

c# - 为什么这个嵌套对象初始值设定项会抛出空引用异常?

c# - WMI:在插入时获取 USB 设备描述

c# - 分部 View 异步加载,不加载,不报错

c# - C#中的线程安全增量

arrays - 以伪随机顺序迭代N维数组的算法

c# - 无法使用来自 EF 的 View 自动生成 Controller

c# - Postgresql/npgsql 在使用丹麦字母时无法写入

javascript - 从 json 对象中删除 json 数组

javascript - 如何使用 forEach 做决定

postgresql - 在 postgresql 数据库上选择查询结果为空。我使用错误的逻辑吗?