MohaMB
New member
- Joined
- Jan 31, 2021
- Messages
- 1
- Programming Experience
- Beginner
I have a bug and I don't know how to fix the bug is the following: I have a list, which in turn is of type <List <String>>, with the constructor what I do is save certain info, and what I have coded is what next:
Then when doing an output I get this:
And what I need is an output like that:
Someone could tell me where the bug is, Thanks!
C#:
List<List<string>> opciones = new List<List<string>>();
public Opcion(){
var opcionesC = File.ReadAllText(this.dir).Split(";R;").ToList();
opcionesC.RemoveAll(item => item == "");
for(int i=0;i<opcionesC.Count;i++){
this.opciones.Add(new List<string>());
string[] opc= opcionesC[i].Split("\n");
foreach(var t in opc){
if(t.IndexOf("Marc")!=-1){
this.opciones[i].Add(t); //HERE ITS WORK
}
if(t.IndexOf("Model")!=-1){
this.opciones[i].Add(t.Remove(0,5)); //HERE IS THE PROBLEM, NOT ADDING
}
if(t.IndexOf("Tip")!=-1){
this.opciones[i].Add(t.Remove(0,3)); //HERE IS THE PROBLEM, NOT ADDING//El problema es esto, no se quiere añadir.
break;
}
}
}
}
C#:
Marca: Audi
Marca: BMW
C#:
Marca: Audi
Modelo: A4
Tipo: Turismo
Marca: BMW
Modelo: S3
Tip:...
Attachments
Last edited by a moderator: