0

I have an object Array

Dummy[] arr = {Dummy1, Dummy2}

I want to join comma separated keys of each Dummy object in that array. This doesn't work.

string blah = string.Join(", ", arr)
4
  • Override the toString() of Dummy object to return the Key! Or select the Key and join Commented Nov 7, 2019 at 16:01
  • 2
    It "doesn't work" because you've made no attempt to access the key. Commented Nov 7, 2019 at 16:03
  • Post the Dummy class. Commented Nov 7, 2019 at 16:08
  • @itsme86 , that was my problem. I couldn't get key value. Tried arr.Key, that doesn't work, obviously Commented Nov 7, 2019 at 16:10

1 Answer 1

4

Something like this?

string blah = string.Join(", ", arr.Select(dummy => dummy.Key));
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.