how to use non static method inside other class without creating object in C# -


I recently changed my project slightly to include the interface for better integration. I'm actually stuck with a way to use a method on my form from a form (which is used to update form control) which comes from my interface. Here are some snippets of code that should help with clarity.

  // This is the double click event from which I choose Private Zero todayEventsGridView_DoubleClick (Object Sender, EventArgs E) {DealModule _dealModule = New Deal module (); // I do not want to make an objection of Class Deal module () {this.Cursor = Cursors.WaitCursor; _dealModule.SelectDeal (DealKey); } Hold (Exception pre) {Message Box. Show ("Warning:" + this.ToString () + "" + System.Reflection.MethodInfo.GetCurrentMethod () .Name + "\ n" + Pre-message, ex.GetType () .tar ()); } Finally {this.Cursor = Cursors.Default; }}   

By definition, it is impossible for examples (non-static) methods Use can be done only when there is an example of class to work with you. You need to either use your class example, or the method need to be declared static.

As Patrick says below, actually you are trying to do this, perhaps indicating a design fault, but it is difficult to suggest how to improve it without further reference.

I add that in the general case, from a design point, it would be better to call against the examples of class (or better, an interface) rather than static methods. It increases testability and helps you achieve loose coupling, making it easy to maintain your software. Why do you think it is better to call a stable method in your case?

Comments

Popular posts from this blog

php - PDO bindParam() fatal error -

logging - How can I log both the Request.InputStream and Response.OutputStream traffic in my ASP.NET MVC3 Application for specific Actions? -

java - Why my included JSP file won't get processed correctly? -