Solved

methods vs functions; types vs classes

Posted on 2003-10-26
3
169 Views
Last Modified: 2010-04-16
I have been reading "C# in a nutshell" and it keeps using the terms functions and types.  Isn't a function the same thing as a method?  And isn't a type the same thing as a class?  I was reading another C# book earlier where it seemed to be just using the terms methods and classes...  :-S

Thanks :)
0
Comment
Question by:chilled2003
  • 2
3 Comments
 
LVL 10

Expert Comment

by:ptmcomp
ID: 9623777
The terms function and type are used in procedural programming. In C# there are no functions outside of classes.
In C# every type is a class but class or a value type (struct). To make it more twisted there is even a class Type which holds the type information (Reflection).
Sample:

string a;

if (a is string) then
{
    // this condition is always true
}

if (a.GetType() == typeof(string))
{
    // this condition is true if a is not null else you'll get a nullreference exception
}
0
 
LVL 10

Accepted Solution

by:
ptmcomp earned 50 total points
ID: 9623786
When you're talking about C# a function is a method. But a type can be a class, a value type. The terms are used differently by different authors but usually you can figure out what is meant.
0
 

Author Comment

by:chilled2003
ID: 9623815
Thanks for the extra clarification :)

I have another question here if you would like to take a look at it as well...

http://www.experts-exchange.com/Programming/Programming_Languages/C_Sharp/Q_20778531.html
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
bulid json format 3 46
WKHTMLTOPDF - --disable-smart-shrinking not working 10 36
C# Single Form 8 27
Entity Framework 7 31
This article describes a simple method to resize a control at runtime.  It includes ready-to-use source code and a complete sample demonstration application.  We'll also talk about C# Extension Methods. Introduction In one of my applications…
Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

910 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now