What is fastest: (int), Convert.ToInt32(x) or Int32.Parse(x)?

后端 未结 15 1176
南笙
南笙 2021-02-02 06:13

Which of the following code is fastest/best practice for converting some object x?

int myInt = (int)x;

or

int myInt = Convert.T         


        
15条回答
  •  温柔的废话
    2021-02-02 06:41

    If you had the need for the extra speed, it would be easy to test the different the different options. Since you aren't testing them, you mustn't need them. Don't waste your time with pointless micro-optimizations!

提交回复
热议问题