Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

Troubleshooting
Research
Professional Opinions
Ask a Question
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

troubleshooting Question

C# - Static vs non-static classes & methods - some clarification please?

Avatar of Number5ix
Number5ixFlag for Australia asked on
C#Microsoft Development
11 Comments1 Solution1138 ViewsLast Modified:
Hi all,

I'm not a professional developer so please excuse my lack of knowledge here ... got a question or 2 for y'all though.

The code sample below is a simple method that obviously returns the result of an identical service method (repository design pattern).  As you can see, it's static.  The method is from a Windows Forms application and in the example it's from the method won't ever be called more than once at a time.  I believe that static methods should always return the same result - is that right?

Why should this method be static/non-static?  If it's only being called from one class at a time does it matter?  The class that contains the method below doesn't get instantiated either - it doesn't need to, I think.

Can someone please explain this if you understand what I'm asking?

Thanks!
public static IList<Application> ListAllApplications(string connStr)
{
   return ApplicationService.ListAllApplications(connStr);
}
ASKER CERTIFIED SOLUTION
Avatar of abel
Commented:
This problem has been solved!
Unlock 1 Answer and 11 Comments.
See Answers