Advertisement
Guest User

Untitled

a guest
Jul 1st, 2021
305
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.50 KB | None | 0 0
  1. void Main()
  2. {
  3.     List<Demo1> demo1 = new List<Demo1> { new Demo1 { PropertyToSet = "Start" } };
  4.     List<Demo2> demo2 = new List<Demo2> { new Demo2 { PropertyToSet = "Start" } };
  5.  
  6.     demo1.ToList().ForEach(c => c.PropertyToSet = "End");
  7.     demo2.ToList().ForEach(c => c.PropertyToSet = "End");
  8.  
  9.     Console.WriteLine(demo1.First().PropertyToSet); //End
  10.     Console.WriteLine(demo2.First().PropertyToSet); //Start
  11. }
  12.  
  13. public class  Demo1 {public string PropertyToSet;}
  14. public struct Demo2 {public string PropertyToSet;}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement