Assuming that GetNames() returns an IEnumerable<string>, we are, effectively, doing extra work by enumerating this collection twice in the two foreach statements.

It could get even worse if GetNames() results in a database query, in which case you could end up getting different values in both foreach loops if some other process changes the database between the two calls.