Class with Static Methods [Resolved]

Posted by Bhupentiwari under C# on 7/6/2016 | Points: 10 | Views : 664 | Status : [Member] | Replies : 4
Hi Guys

I have one class called "CommonFunction" with more than 137 static method.

I am using this class on all forms [wherever required]

Please suggest me will it affect my application performance if yes then how ??

Thanks n Regards
Bhupendra Tiwari



Responses

Posted by: Rajnilari2015 on: 7/6/2016 [Member] [Microsoft_MVP] [MVP] Platinum | Points: 50

Up
0
Down

Resolved
@Bhupentiwari Sir, Static calls are generally faster in nature than instance method calls. They perform much better while tested on loops that calls it for a large number of times. (https://msdn.microsoft.com/en-us/library/ms973852.aspx )

But IMHO, placing 137+ static methods in a single class is a little cumbersome. Better to refactor for maintainability.

Another option is to create Extension Methods wisely and use it.

Hope this helps.

--
Thanks & Regards,
RNA Team

Bhupentiwari, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: A2H on: 7/6/2016 [Member] [MVP] Silver | Points: 25

Up
0
Down
IMO, Performance depends on the actual processing time of your static methods. If your static method is processing faster then each time you call it will process it faster and you wont see any performance issues in your application. However if you method take time to process then you will get slower response.

In other words static method is a way to call a method multiple time with out repeating the similar codes again and again and the performance depends on the overall processing time of logic inside static method

Thanks,
A2H
My Blog

Bhupentiwari, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Amatya on: 7/13/2016 [Member] Silver | Points: 25

Up
0
Down
Not a problem for performance Issue.

Feel free to share informations 9731764134
mail Id ' adityagupta200@gmail.com
Thanks

Bhupentiwari, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Bhuvanesh6 on: 7/31/2016 [Member] Starter | Points: 25

Up
0
Down
Static will always have a single instance and will not effect performance.

Bhuvan

Bhupentiwari, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response