C
C#17mo ago
Ropix

❔ Text file

So I am wondering how this works, so I am calling a textfile and then splitting it into multiple and checking if the user input is anywhere in the textfile but havent done it because I dont really understand how and if the split function works for multiple lines
189360200;Bosch;174;60;black;2000;2;62;29;
535981394;Tefal;90;700;bronze;320;Third Rack;Qt;
516089502;Hoover;240;1200;silver;250;Finger Print Resistant;Qr;
255131796;Black & Decker;55;1500;white;500;Residential;18;
254565387;Miele;86;1000;grey;800;Commercial;24;
571522655;Philips;228;440;grey;390;Finger Print Resistant;M;
263788832;Hoover;59;600;black;750;Residential;18;
408018499;Bosch;54;500;white;250;Third Rack;Qu;
143826003;Kenwood;0;4700;silver;1500;2;62;32;
231784690;Russell Hobbs;155;175;grey;380;Residential;18;
243074424;Tefal;61;4000;black;760;Residential;18;
297972916;Dyson;104;1400;bronze;530;Commercial;24;
146947171;Black & Decker;112;1800;grey;1800;3;70;31;
302618394;Hoover;159;100;white;99.99;1.1;K;
493374445;Philips;125;1650;silver;510;Clean with Steam;M;
383477937;Miele;201;2350;white;179.9;1.8;K;
119638199;Vax;134;1200;black;2650;4;66;29;
244733872;Bosch;133;700;grey;430;Commercial;24;
587065284;Kenwood;74;1010;silver;430;Clean with Steam;Qu;
240201796;Dyson;81;1050;white;290;Residential;18;
172911121;Philips;144;700;black;3100;3;71;30;
328237584;Miele;90;1200;bronze;250.23;2.1;W;
118963476;Russell Hobbs;146;1150;grey;2360;4;73;32;
333607621;Vax;113;440;silver;123.99;1.6;W;
274807482;Black & Decker;30;1800;black;375;Commercial;24;
189360200;Bosch;174;60;black;2000;2;62;29;
535981394;Tefal;90;700;bronze;320;Third Rack;Qt;
516089502;Hoover;240;1200;silver;250;Finger Print Resistant;Qr;
255131796;Black & Decker;55;1500;white;500;Residential;18;
254565387;Miele;86;1000;grey;800;Commercial;24;
571522655;Philips;228;440;grey;390;Finger Print Resistant;M;
263788832;Hoover;59;600;black;750;Residential;18;
408018499;Bosch;54;500;white;250;Third Rack;Qu;
143826003;Kenwood;0;4700;silver;1500;2;62;32;
231784690;Russell Hobbs;155;175;grey;380;Residential;18;
243074424;Tefal;61;4000;black;760;Residential;18;
297972916;Dyson;104;1400;bronze;530;Commercial;24;
146947171;Black & Decker;112;1800;grey;1800;3;70;31;
302618394;Hoover;159;100;white;99.99;1.1;K;
493374445;Philips;125;1650;silver;510;Clean with Steam;M;
383477937;Miele;201;2350;white;179.9;1.8;K;
119638199;Vax;134;1200;black;2650;4;66;29;
244733872;Bosch;133;700;grey;430;Commercial;24;
587065284;Kenwood;74;1010;silver;430;Clean with Steam;Qu;
240201796;Dyson;81;1050;white;290;Residential;18;
172911121;Philips;144;700;black;3100;3;71;30;
328237584;Miele;90;1200;bronze;250.23;2.1;W;
118963476;Russell Hobbs;146;1150;grey;2360;4;73;32;
333607621;Vax;113;440;silver;123.99;1.6;W;
274807482;Black & Decker;30;1800;black;375;Commercial;24;
and my code wouldnt fit so https://wtools.io/paste-code/bJ6z
WEB Tools
updated text code
using System; using System.Collections.Generic; using System.IO; using System.IO.Pipes; using System.Linq; using System.Runtime.Remoting.Met
9 Replies
Ropix
Ropix17mo ago
i updated it, i have all the split variables in one so can i call it from outside to get the user input and check if it matches anay\
Esa
Esa17mo ago
So what exactly is your question? You're on the right path, but I would prefer to not use foreach personally.
Ropix
Ropix17mo ago
so i was hoping to split the text file with ; and ask a user to input the appliance id whichis the first part of the text file the numbers and if that number is in then it will say accepted and if not it will say rejected
mtreit
mtreit17mo ago
Consider making a class or record to represent each appliance instead of just using a bunch of free floating variables. Then you can put those into some data structure to allow lookup by various attributes. A List<Appliance> being a simple starting point if you know the data will not be large.
Ropix
Ropix17mo ago
string<Apps> Apps = new List<Apps>();
string<Apps> Apps = new List<Apps>();
string<Apps> Apps = new List<Apps>();

foreach (string line in lines);
{
string[] items = lines.split(";");
Apps id = items[0];
string name = items[1];
string value = items[2];
Apps.Add(id)
}
string<Apps> Apps = new List<Apps>();

foreach (string line in lines);
{
string[] items = lines.split(";");
Apps id = items[0];
string name = items[1];
string value = items[2];
Apps.Add(id)
}
kinda like this? or remove it from foreach?
mtreit
mtreit17mo ago
string<Apps>
string<Apps>
...well that's not a thing Do you know how classes work?
Ropix
Ropix17mo ago
kinda oh so we gotta call one of the classes made and not a new one so appliance
Ropix
Ropix17mo ago
Accord
Accord17mo ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.