How can I optimize this code for speed and less resource consumption? When come large count like int.MaxValue it work very long:
public stati