存取清单清单 [英] Access List of List

查看:78
本文介绍了存取清单清单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个列表列表来存储随机生成的数据,但是我的实现显示以下智能提示错误变量名称在当前上下文中不存在".我哪里出问题了?这是我的代码的必需部分.

I created a List of List to store randomly generated data however my implementations shows the following intellisense error "The variable name doesn't exist in current context". Where have I gone wrong? Here are the required portions of my code.

           List<List<string>> DataList = new List<List<string>>();
           //Some Code
            for (int i = 0; i < num; i++)
            {
                List<string> strVal = new List<string>();
                foreach (string someVal in SomeList)
                {                    
                    //Some Code
                    strVal.Add(data);
                }

                DataList.Add(strVal);
            }

            for (int i = 0; i < num; i++)
            {
                foreach (IList<string> name in DataList)
                {
                    foreach (string listVal in strVal) // Error Here
                    {
                        //Some Code
                    }                    
                }
            }

我哪里出问题了?谢谢.

Where have I gone wrong? Thanks.

推荐答案

  foreach (IList<string> name in DataList)
            {
                foreach (string listVal in strVal) // Error Here
                {
                    //So

应该是

  foreach (IList<string> name in DataList)
            {
                foreach (string listVal in name ) // Error Here
                {
                    //So

这篇关于存取清单清单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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