Sort string of comma separated numbers using C# and VB.Net in Console Application

Last Reply 4 months ago By dharmendr

Posted 4 months ago
Write a C# console app called NumberParser which accepts a comma delimited list of integers as the first parameter, and a file format as the second parameter. The app would be invoked via the command line like this - NumberParser 4,5,1,9,10,58,34,12,0 XML. 

The app should parse the first parameter into an array of integers, sort it into descending order and then persist it in the specified format. The app should support text files, XML and JSON formats.

As well as delivering the requirements, the solution should demonstrate how to use an interface and how to use the factory pattern.

NumberParser 4,5,1,9,10,58,34,12,0  Txt.

Read the numbers and sort it in descending along with the format.

output: 58 34 12,10,9,5,4,1,0 Txt

Same way for XML

NumberParser 4,5,1,9,10,58,34,12,0 XML. 

output: 58 34 12,10,9,5,4,1,0 XML

Same way for JSON

NumberParser 4,5,1,9,10,58,34,12,0 JSON.

output: 58 34 12,10,9,5,4,1,0 JSON

This question does not have replies that have been liked.