V
V
Vitya Podpriklopolny2021-11-29 13:01:28
C++ / C#
Vitya Podpriklopolny, 2021-11-29 13:01:28

How to write this in C#?

JS has a data structure like this

const data = [
  { bill: '123123', amount: 3.25 },
  { bill: '121231', amount: 5 }
]

But how to write this in C# so that new elements can be added? Do I understand correctly that this will be a list from the Dictionary?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
Vladimir Korotenko, 2021-11-29
@megamage

var list = new List<Bill>();
list.Add(new Bill{Bill = 12345, Amount= 6666.6}) ;
var item = list.FirstOrDefault(x=>x.Bill == 12345);

R
Ronald McDonald, 2021-11-29
@Zoominger

Dictionary
https://metanit.com/sharp/tutorial/4.9.php

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question