method vs function vs procedure vs class
method vs function vs procedure vs class
class?
Ask Question
Asked 14 years, 4 months ago
Modified 4 years, 5 months ago
Viewed 23k times
15
I know the basics of this methods,procedures,function and classes but i always
confuse to differentiate among those in contrast of Object oriented
programming so please can any body tell me the difference among those with
simple examples ?
c
objective-c
oop
Share
Improve this question
Follow
asked Jun 14, 2010 at 10:01
2easylogic
4
One of these terms does not really fit to the others :) (with respect to comparability)
– Felix Kling
CommentedJun 14, 2010 at 10:04
Add a comment
4 Answers
Sorted by:
Highest score (default)
Trending (recent votes count more) Date modified
(newest first) Date created (oldest first)
30
A class, in current, conventional OOP, is a collection of data (member variables)
bound together with the functions/procedures that work on that data (member
functions or methods). The class has no relationship to the other three terms
aside from the fact that it "contains" (more properly "is associated with") the
latter.
The other three terms ... well, it depends.
void setMemberVariableProcedure(int v)
{
memberVariable = v;
}
int getMemberVariableFunction()
{
return memberVariable;
}
};
The only differences I can think between these three and the places where they
are used.
I mean 'method' are generally used to define functions inside a class, where
several types of user access right like public, protected, private can be defined.
"Procedures", are also function but they generally represent a series of function
which needs to be carried out, upon the completion of one function or parallely
with another.
Classes are collection of related attributes and methods. Attributes define the
the object of the class where as the methods are the action done by or done on
the class.
A subroutine is:
Dinesh Jethoe
3122 bronze badges
Please provide Objective-C examples instead of SQL.
– Willeke
CommentedApr 26, 2020 at 10:16
Add a comment
0
There is no difference between of among. Method : no return type like void
Function : which have return type
15. Functions and procedures in C#
Página 15
Functions in C#
Functions in C#, also known as methods, are blocks of code that perform a
specific task. They may or may not return a value. Functions help break code
into smaller, more manageable segments, making it easier to read and
maintain.
A function in C# is declared as follows:
In this example, 'public' is the access modifier that determines the visibility
of the role. 'int' is the return type of the function, which specifies the type of
value that the function returns. 'Sum' is the name of the function. 'int num1,
int num2' are the function parameters, which are the values that the function
receives when it is called.
Procedures in C#
Procedures in C# are a specific type of function that does not return a value.
In other words, the return type of the procedure is 'void'. Just like functions,
procedures also help break code into smaller, more manageable segments.
A procedure in C# is declared as follows:
public void DisplayMessage()
Console.WriteLine("Hello, World!");
In this example, 'public' is the access modifier, 'void' is the return type of the
procedure, which indicates that the procedure does not return a value.
'DisplayMessage' is the name of the procedure. This procedure has no
parameters.
DisplayMessage();
Conclusion
Functions and procedures are fundamental in C# programming, as they
allow us to divide our code into smaller, more manageable blocks. This not
only makes our code easier to read and maintain, but it also allows us to
reuse the code, which can save a lot of time and effort.
We hope this chapter has given you a good understanding of functions and
procedures in C#. In the next chapter, we'll delve deeper into other C#
programming concepts important for game development with Unity.
Types of C# Arrays
There are Three types of Arrays in C#:
2. Multidimensional Arrays
3. Jagged Arrays
Now, discuss them in detail, and get started with Single dimensional Arrays.
Code:
using System;
{
int[] array= {10, 15,13,9,21};//Array definition
for(int j=0;j<array.Length;j++)
Console.WriteLine(array[j]);
Code:
for(int i=0;i<3;i++){
for(int j=0;j<3;j++){
Console.WriteLine(array[i,j]+" ");
Console.WriteLine();
}
What Are Jagged C# Arrays?
Code:
using System;
array[0]=new int[6]{42,61,37,41,59,63};
array[1]=new int[4]{11,21,56,78};
for(int i=0;i<array.Length;i++)
for(int j=0;j<array[i].Length;j++)
System.Console.Write(arr[i][j]+" ");
}
System.Console.WriteLine();
And these are the types of C# Arrays. Now have a look at the advantages of
C# Arrays.
Advantages of C# Arrays
Data structures, like linked lists, stacks, trees, and queues, are
implemented using arrays.
The array size is fixed. So, you must declare the size of the array
beforehand.
Advance your career as a MEAN stack developer with the Full Stack Web
Developer - MEAN Stack Master's Program. Enroll now!
Basics to Advanced - Learn It All!
Caltech PGP Full Stack DevelopmentEXPLORE PROGRAM
Next Steps
"C# Interfaces" can be your next concept to learn. For example, in C#, the
Interface is like a class blueprint. However, as with abstract classes, any
methods declared within an interface are abstract methods. For example, it
doesn't have a method body.
pp_pankaj
Follow
46
Previous Article
Difference between SRS and FRS
Next Article
Project Size Estimation Techniques - Software Engineering
Similar Reads