Click here to Skip to main content
15,889,116 members
Please Sign up or sign in to vote.
2.00/5 (1 vote)
i m new in c# i have an array values like this

id name subject marks
1 jhone math 60
2 smith science 50
3 clark math 90
1 jhone science 80
3 clark science 56
1 jhone ecnomics 75
2 smith math 40
3 clark ecnomics 99

first i want to sort array like this
id name subject marks
1 jhone math 60
1 jhone science 80
1 jhone ecnomics 75

2 smith science 50
2 smith math 40

3 clark math 90
3 clark science 56
3 clark ecnomics 99

array.sort command working..okk

now i want to concatenate these values and answer show like this
1,jhone,math 60,science 80,ecnomics 75
3,clark,math 90,science 56,ecnomics 99

Remember id 2 not display contenate bcz id 2 have 2 subjects..his ecnomics result is pending..so only show this result

1,jhone,math 60,science 80,ecnomics 75
3,clark,math 90,science 56,ecnomics 99


please solve my problem
thanks in advance
Posted

1 solution

You will have to write your own logic to do it.

You will need a loop to navigate to each value in the array after you have sorted the results. Declare a string variable and concatenate the required parts. The value in the string will be complete only when you find 3 subjects for the same id.

It isn't very hard. You just need to start trying. See what I have suggested and start implementing it. The debugger will come handy in doing this. Come back when you have tried and have 'specific' issue.

Good luck!
 
Share this answer
 
Comments
Olivier Levrey 4-Apr-11 6:03am    
I agree with Ankur. Write some code and whenever you have a specific problem, come back here, click "improve question" and explain what is not working as expected.
Ankur\m/ 4-Apr-11 6:06am    
Thanks for your support and vote. :)
Sergey Alexandrovich Kryukov 5-Apr-11 1:13am    
Agree, my 5.
--SA
Ankur\m/ 5-Apr-11 1:53am    
Thank you so much. Your vote matters a lot to me.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900