How to speed up Word Interop processing?

前端 未结 4 1141
悲&欢浪女
悲&欢浪女 2021-01-21 12:03

I am Very new at C# and have written a fairly clunky code. I have been doing a lot of courses online and a lot say that there are several ways to approach problems. Now i have m

4条回答
  •  傲寒
    傲寒 (楼主)
    2021-01-21 12:49

    Instead of using:

    document.Words[i].Text
    

    multiple times, do:

    String Text = document.Words[i].Text;
    

    at the top of the for loop and use "Text" (or whatever you want to call it) instead. Eugene Podskal's suggestions seem very helpful but this simple improvement (that I was thinking of before seeing Eugene's response) is very easy to do and could make a substantial improvement.

提交回复
热议问题