遍历List< string []> [英] looping through a List<string[]>

查看:109
本文介绍了遍历List< string []>的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试获取数组列表中具有索引的每个项目的值,我使用此代码完成了此操作,但是循环结束后没有显示值.

I am trying to get the values for each item with index inside array list i did it with this code but don't have values display after loop finished.

foreach (var item in (List<string[]>)TempData["verification_errors"])
{
    <p>@item[0].ToString() + @item[2].ToString()</p>
}

这是List<string[]>

List<string[]> Data_verification_errors = new List<string[]>();
string[] Cust_Surname = new string[] { "CustomerSurname", reservation_details.CustomerSurname, "Customer name must have at least 2 characters" };

Data_verification_errors.Add(Cust_Surname);

推荐答案

在循环内部更改为:

<p>@(item[0].ToString() + item[2].ToString())</p>

代替:

<p>@item[0].ToString() + @item[2].ToString()</p>

这篇关于遍历List&lt; string []&gt;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆