[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

methods vs functions; types vs classes

Posted on 2003-10-26
3
Medium Priority
?
176 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 200 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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
Suggested Courses
Course of the Month19 days, 1 hour left to enroll

834 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