Ooya

https://www.codecademy.com/paths/build-web-apps-with-asp-net/tracks/build-web-apps-asp-net-intermediate-c-sharp/modules/learn-csharp-classes/projects/csharp-dating-profile

In the ForEach loop, where it is appending the hobbies to the bio string, I’m slightly confused about the line of code inbetween the brackets ( bio +=$"- {hobby} \n"; ) i kept thinking that the answer you guys provided was going to repeat the whole bio string 4 times, and then adding each hobby, which would have been a really messy result, so I had tried to assign the hobbies to a new string on it’s own which wasn’t working at all.

I guess my question is what does += mean or do?

foreach (string hobby in hobbies)
{
bio +=$"- {hobby} \n";
}
}
return bio;

Hello, @amandadelongchamp429, and welcome to the forums.

The += operator concatenates the right operand to the left one. For example:

string bio = "some string ";
//the following two statements are equivalent:
bio = bio + "some additional string ";
bio += "another additional string";

Console.WriteLine(bio); //prints: some string some additional string another additional string 
1 Like