Please enable / Bitte aktiviere JavaScript!
Veuillez activer / Por favor activa el Javascript![ ? ]
How to write c# code when using classes? - bug-code.com Q&A

How to write c# code when using classes?

0 like 0 dislike
23 views
I have a class that has 2 properties that take integer values. In the main code stream, I'm writing a loop through which to record list of n instances of the class. Then I suppose you need to sort these instances by any field. And I need it to apply? Create a separate class for sorting? Just in the main code stream(progtam) to write this sort? Or in the main thread code to execute it as a procedure?And the same with all the other things, I/o, etc. As everything is made? In a separate procedure, or also with classes?
asked by | 23 views

2 Answers

0 like 0 dislike
The solution of your problem suppose to be ten. They will all be different and solve a problem. For example:
1) Write the class comparator and sort it
2) create an instance of the comparator from the reference comparison method
3) create an instance comparator from the lambda comparison
4) send a link to the method of comparison in the Sort method of the list
5) Transfer the lambda comparison in the Sort method of the list
6) the Implementation of IComparable and call Sort with no parameters
7) Implement one of the sorting algorithms in a separate method and call this method
8) Implement one of the sorting algorithms in a separate class with the spreading code for the individual methods of a class
9) Sort the bubble right in the Main
10) Put everything in a database through a user-friendly ORM and the select with correct order to in the correct order

What to choose depends on a) volume of sorted data b) available time for development) budgets-memory and CPU d) coding style in the company, d) personal preference and knowledge.

Which one is "correct"? All. Which one to choose? As experience suggests, will experience with him will understand what choices to make.
answered by
0 like 0 dislike
Can be different, for example: c-sharp.pro/?p=1192
answered by
Welcome to Bug-code Q&A, where you can ask questions and receive answers from other members of the community.

24.8k questions

46.2k answers

0 comments

12.7k users

24,788 questions
46,220 answers
0 comments
12,722 users