[Solved] how i can get the data that stored in list [closed]


First off, you’re going to need to make sure that the ConnectedUser that you randomly get is not the same user you are linking to, before you add that connection, or you’re going to find further issues.

For ConnectedUser, you can get the index by simply using ConnectedUser[x]. (I suggest making your lists plural so it’s obvious that they’re collections.)

You need to assign that connected user to a new object.
Something like

UserID linkedUser = ConnectedUser[x];

This way, you can reference linkedUser.ConnectionId in your connection addition.

Alternately, you could just use:

Connection.Add(new ConnectionsId { ConnectionId = id, ConnectionId2 = ConnectedUser[x].ConnectionId };

This random setup, though, does have a strong potential for having several people ending up not linked to anyone. Additionally, your line that states:

if (ConnectedUser.Count != 0 ...

is redundant. You just added a user to that list. It should never be of size 0.

3

solved how i can get the data that stored in list [closed]