不更改数据量 [英] Does not change the amount of data

查看:59
本文介绍了不更改数据量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,所有

我有一个奇怪的问题,我在c#中有程序.列表中的< ,无论何时初始值列表更改,作为初始值的命令都将读取或显示这些命令,或者它们无法正常工作:例如,命令查找"(Find)会显示在列表中. :未找到新项目 ,或命令"FindIndex" :找不到新的索引项,等等.首先,我进行编程.像城市一样,我在列表中找到索引并显示我的城市.索引的容量及其查找和显示的能力.我正在编写代码 程序的内容:

            int j = 0;
          布尔值find = false;
           int indexDomestic = 0;

           List< string> domesticFlights = new List(string)(){"Shiraz","Kish","Tehran","Mashhad","Isfahan" }; 

           List< double> PriceInTheDomesticFlights = new List< double>(){75000,90000,60000,85000,70000};
           List< int> InTheCapacityOfDomasticFlights = new List< int>(){5,6,4,0,1};

           for(int i = 0; i< domesticFlights.Count; i ++)
            {
                             Console.WriteLine(domesticFlights [i] +"\ t" + PriceInTheDomesticFlights [i] +"\ t" +

                InTheCapacityOfDomasticFlights [i] +"\ t" + InInternationalFlights [i] +"\ t" + PriceInInternationalFlights [i] +"\ t"  

                        + CapacityInInternationalFlights [i]);
             }
              Console.WriteLine(您是否要乘坐国内航班?(y/n)");
            字符串类型= Console.ReadLine();
             Console.WriteLine(您要飞往哪个城市?");
             字符串namecity = Console.ReadLine();

              一会儿(j< domesticFlights.Count&&查找==否)
              {
                   如果(domesticFlights [j] == namecity)
                 {
                    find = true;
                   字符串city = domesticFlights.Find(s => s == namecity);
                    indexDomestic = domesticFlights.FindIndex(a => a ==城市);
                    int indexcapacity = InTheCapacityOfDomasticFlights.Find(q => q == indexDomestic);
                    int showindexcapacity = InTheCapacityOfDomasticFlights.FindIndex(s => s == indexcapacity);

                       for(int i = 0; i< InTheCapacityOfDomasticFlights.Count; i ++)
                    {
                 如果(InTheCapacityOfDomasticFlights [i] == showindexcapacity)
              nbsp; bsp   {
              nbsp; bsp     Console.WriteLine("showindexcapacity =" + showindexcapacity);
]      }
              nbsp; bsp  其他
                 {
              nbsp; bsp    Console.WriteLine(错误!");
                 }
                       }

              b ; Console.WriteLine("city =" +城市+"\ t" +"indexDomestic =" + indexDomestic);
                      }
                     其他
] {
                    Console.WriteLine(找不到");

                             }
                             j ++;
                             }

请帮助我,谢谢!

解决方案

您好shadi golroz,

谢谢您在这里发布.

对于您的问题,我将测试您的代码.在您的代码中,您自己定义了一些内容,例如 InInternationalFlights, PricesInInternationalFlights, 我使用 例如InTheCapacityOfDomasticFlights.  您可以尝试以下代码.

静态void Main(string [] args)
        {
            int j = 0;
            布尔值find = false;
            int indexDomestic = 0;
            List< string> domesticFlights = new List(string)(){"Shiraz","Kish","Tehran","Mashhad","Isfahan" };
            List< double> PriceInTheDomesticFlights = new List< double>(){75000,90000,60000,85000,70000};
            List< int> InTheCapacityOfDomasticFlights = new List< int>(){5,6,4,0,1};

            为(int i = 0; i 

我希望这会有所帮助.

如果您对此问题还有其他疑问,请随时与我们联系

最好的问候,

Wendy


Hi, All

I have a strange problem,I have program in c# . in the List<> , anytime initial value list change , the commands that is initial value read or display these work , Not working properly : for-example the command "Find" : new item not found , or the command "FindIndex" : new index item not found , etc .First, an explanation I program .Like the city and I find the index in the list and display my city also The index of capacity and its capacity to find and display.I am writing the code of a program :

            int j = 0;
            Boolean find = false;
            int indexDomestic = 0;

            List<string> domesticFlights = new List<string>() { "Shiraz", "Kish", "Tehran", "Mashhad", "Isfahan" }; 

            List<double> PricesInTheDomesticFlights = new List<double>() { 75000, 90000, 60000, 85000, 70000 };
            List<int> InTheCapacityOfDomasticFlights = new List<int>() { 5, 6, 4, 0, 1 };

            for (int i = 0; i < domesticFlights.Count; i++)
              {
                Console.WriteLine(domesticFlights[i] + "\t" + PricesInTheDomesticFlights[i] + "\t" + 

                InTheCapacityOfDomasticFlights[i] + "\t" + InInternationalFlights[i] + "\t" + PricesInInternationalFlights[i] + "\t"  

               + CapacityInInternationalFlights[i]);
              }
               Console.WriteLine(" Do you want to domestic flights ? (y/n)");
               string type = Console.ReadLine();
               Console.WriteLine("Which city do you want to fly ? ");
               string namecity = Console.ReadLine();

               while (j < domesticFlights.Count && find == false)
               {
                    if (domesticFlights[j] == namecity)
                   {
                    find = true;
                    string city = domesticFlights.Find(s => s == namecity);
                    indexDomestic = domesticFlights.FindIndex(a => a == city);
                    int indexcapacity = InTheCapacityOfDomasticFlights.Find(q => q == indexDomestic);
                    int showindexcapacity = InTheCapacityOfDomasticFlights.FindIndex(s => s == indexcapacity);

                       for (int i = 0; i < InTheCapacityOfDomasticFlights.Count; i++)
                       {
                           if (InTheCapacityOfDomasticFlights[i] == showindexcapacity)
                           {
                              Console.WriteLine("showindexcapacity=" + showindexcapacity);
                           }
                           else
                          {
                            Console.WriteLine("There is a wrong !");
                          }
                          }

                         Console.WriteLine("city=" + city + "\t" + "indexDomestic =" + indexDomestic);
                        }
                        else
                  {
                    Console.WriteLine("Not Found");

                }
                j++;
                }

Please help me, thanks!

解决方案

Hi shadi golroz,

Thank you for posting here.

For your question, I test your code. In your code, there are some defined by yourself like InInternationalFlights, PricesInInternationalFlights, CapacityInInternationalFlights. I ignore it when I test your code.

I use InTheCapacityOfDomasticFlights for example. If you want input city like Kish, it will output the capacityOfDomasticFlights and Price. You could try the following code.

 static void Main(string[] args)
        {
            int j = 0;
            Boolean find = false;
            int indexDomestic = 0;
            List<string> domesticFlights = new List<string>() { "Shiraz", "Kish", "Tehran", "Mashhad", "Isfahan" };
            List<double> PricesInTheDomesticFlights = new List<double>() { 75000, 90000, 60000, 85000, 70000 };
            List<int> InTheCapacityOfDomasticFlights = new List<int>() { 5, 6, 4, 0, 1 };

            for (int i = 0; i < domesticFlights.Count; i++)
            {
                Console.WriteLine(domesticFlights[i] + "\t" + PricesInTheDomesticFlights[i] + "\t" + InTheCapacityOfDomasticFlights[i] + "\t");
            }
            Console.WriteLine(" Do you want to domestic flights ? (y/n)");
            string type = Console.ReadLine();
            if (type == "y")
            {
                Console.WriteLine("Which city do you want to fly ? ");
                string namecity = Console.ReadLine();
                while (j < domesticFlights.Count && find == false)
                {
                    if (domesticFlights[j] == namecity)
                    {
                        find = true;
                        string city = domesticFlights.Find(s => s == namecity);
                        indexDomestic = domesticFlights.FindIndex(a => a == city);
                        int indexcapacity = InTheCapacityOfDomasticFlights[indexDomestic];
                        double indexPrice = PricesInTheDomesticFlights[indexDomestic];
                        //int indexcapacity = InTheCapacityOfDomasticFlights.Find(q => q == indexDomestic);
                        //int showindexcapacity = InTheCapacityOfDomasticFlights.FindIndex(s => s == indexcapacity);
                        //for (int i = 0; i < InTheCapacityOfDomasticFlights.Count; i++)
                        //{
                        //    if (InTheCapacityOfDomasticFlights[i] == showindexcapacity)
                        //    {
                        //        Console.WriteLine("showindexcapacity=" + showindexcapacity);
                        //    }
                        //}
                        Console.WriteLine("city={0} indexcapacity={1} indexPrice={2}", city, indexcapacity, indexPrice);
                    }
                    j++;
                }
            }
            Console.ReadKey();
        }

Here is the output.

I hope this would be helpful.

If you have something else about this issue, please feel free to contact us.

Best Regards,

Wendy


这篇关于不更改数据量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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