So I seem to be confident that the following 2 statements are the same
List<object> values = new List<object>();
values.ForEach(value => System.Diagnostics.Debug.WriteLine(value.ToString()));
AND
List<object> values = new List<object>();
values.ForEach((object value) => {
System.Diagnostics.Debug.WriteLine(value.ToString());
});
AND I know I can insert multiple lines of code in the second example like
List<object> values = new List<object>();
values.ForEach((object value) => {
System.Diagnostics.Debug.WriteLine(value.ToString());
System.Diagnostics.Debug.WriteLine("Some other action");
});
BUT can you do the same thing in the first example? I can't seem to work out a way.
Yes you can :)
List<object> values = new List<object>();
values.ForEach(value =>
{
System.Diagnostics.Debug.WriteLine(value.ToString());
System.Diagnostics.Debug.WriteLine("Some other action");
}
);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With