c# - using static methods or instantiate the class? -


Recently I got a dispute about the use of static methods in the square used by hundreds of threads . In my opinion there is no special advantage of "first" solution, besides it is easy to use for a class customer but I have been told that this is a very bad idea and I have to use the "second" solution Can I explain how wrong I am? Thanks a lot!

Let's assume the dictionary thread is safe.

  class A {static dictionary & lt; Int, string & gt; M_dic = New Dictionary & lt; Int, string & gt; (); Public static string GetData1 (int nKey) {return m_dic [nKey]; } Public string GetData2 (int nKey) {return m_dic [nKey]; }} // These Functions have been called with Threads ... Zero Threadfunk 1 () {Print A. Gate Data 1 (1); } Zero ThreadFunc2 () A A = new A (); Print a.getdata2 (1); }  

Regards, Leonid

Using an example member (for me, at least) is something relevant about the example - either its position, or possibly in case of override methods Behavior (such as "state" is example execution time type).

In this case none of these is true - so I would like to make an example as a wrong style, which would be a misleading code.


Comments

Popular posts from this blog

paypal - How to know the URL referrer in PHP? -

oauth - Facebook OAuth2 Logout does not remove fb_ cookie -

wpf - Line breaks and indenting for the XAML of a saved FlowDocument? -