L
L
LoliDeveloper2020-09-07 07:17:24
C++ / C#
LoliDeveloper, 2020-09-07 07:17:24

How to optimize a C# program?

How can you learn to write programs effectively?
I now know that it is necessary to use an Array, not a List, where it is possible.
But there is something else like that that you need to think about while writing a program. How to learn to think what is more efficient to use? Maybe some books...

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
Vladimir Korotenko, 2020-09-07
@LoliDeveloper

Don't think about it at all. From the word at all.


I now know that it is necessary to use an Array, not a List, where it is possible.

That is, you deliberately complicate your life and use a slower solution, because someone told you.
The general rules are:
* Do not optimize
* Write in a way that is understandable
* You can always mess up *
You will always make a mistake
* Only the profiler will tell you exactly!!!
Here is an example of the code already finished for the performance.
https://github.com/vkorotenko/FiasServer/blob/mast...
See how these variables are used
private List<NormativeDocument> _normDocs;
private HashSet<Guid> _normDocIds;

H
HemulGM, 2020-09-07
@HemulGM

They will not write you here a few points that you will apply and everything will be fine with you. So it doesn't work.
Isn't it clear that you need to read books? Yes, there are even books specifically on optimization. Only you will be surprised, but optimization often occurs at the level of the algorithm, and not at the level of "this type of variable is more profitable than that one."
There are many books and solutions. And here you are demonstrating to everyone your inability to think with your head on your own.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question