Quantcast
Channel: Latest Questions by esitoinatteso
Viewing all articles
Browse latest Browse all 92

Check if Exists and if so, Add it to Other List

$
0
0
Hi there! I've just experienced an odd issue and I'd like to be enlightened on this topic. I'm posting a piece of code in which I'm inside a switch, but that's not so important; what matters is that ** I'd like to check if in the list called mirror exists one object with a certain value and if so, add it immediately to a second list called Lpositions**. Since I'm already checking if something like that exists *it would be awesome to be able to just address that " x" and say: Lpositions.Add(x.position)!* but that returns an error... how sad. Could you help me? I'm self-teaching me C# so if you could elaborate a bit your answer or pass me a link of not-too-complicated code I'd really appreciate. Thanks for your time! //Check if something other than rand is empty in our mirror list case 2: //hypotheticalActorsOnPoint is the value I want to check if(mirror.Exists(x => x.hypotheticalActorsOnPoint == 0)){ for(int j = 0; j < mirror.Count; j++){ if(mirror[j].hypotheticalActorsOnPoint == 0){ Lpositions.Add(mirror[j].position); mirror[j].hypotheticalActorsOnPoint++; i++; //this code is inside a while loop too if(mirror[j].isFull){ mirror.Remove(mirror[j]); } break; } } break; } else{ goto default; }

Viewing all articles
Browse latest Browse all 92

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>