Click here to Skip to main content
15,881,172 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
How do I declare functions in C#?
Posted
Updated 29-Jun-10 22:24pm
v4

Start here[^] read everything.
 
Share this answer
 
All functions are part of a class, they're usually called methods.

private/public int myMethod (int param);


This method takes an int as input and returns an int.

Cheers
 
Share this answer
 
[modifier] [return type] [founction name](parm)
{
// write code here
}
ie
public int add(int a,int b)
{
int sum=a+b;
return sum;
}
 
Share this answer
 
General Syntax :
[Access Modifier][Returned Data Type][function name](Paramters)

Ex :
1)
public int FunctionName (int x,int y)
{
// Your Custom Code go here
}

2)
Private Void Add(int x ,int y)
{
Console.WriteLine (x + y);
}
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900