Guest User

Untitled

a guest
Dec 12th, 2017
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.85 KB | None | 0 0
  1. static void Main(string[] args)
  2. {
  3. var list = new List<MyObj>
  4. {
  5. new MyObj { TransType = "Credit", PaymentMethod = 1, Amount = 1000 },
  6. new MyObj { TransType = "Debit", PaymentMethod = 2, Amount = 2000 },
  7. new MyObj { TransType = "Debit", PaymentMethod = 1, Amount = 4000 },
  8. new MyObj { TransType = "Credit", PaymentMethod = 3, Amount = 3000 }
  9. };
  10.  
  11. var filtered = from o in list
  12. where o.TransType == "Credit"
  13. select new
  14. {
  15. o.TransType,
  16. o.PaymentMethod,
  17. o.Amount,
  18. Credit = "<VALUE>",
  19. Debit = "<VALUE>"
  20. };
  21. }
  22. class MyObj
  23. {
  24. public string TransType { get; set; }
  25. public int PaymentMethod { get; set; }
  26. public int Amount { get; set; }
  27. }
Add Comment
Please, Sign In to add comment