Function / How to create a function / Type /how to access function/ Access function with object
Function:-(most important)
-Function is a small job program
Function terminologies:-
function separator()
eg-
display()
*How to create a function :-
Syntax:-
type functionName()
{
}
- Type:-
-Type is representing types of function (int , string, double)
-by default all function is to be created void type
eg-
void display()
{
}
void show()
{
}
Note:- All function is to be created before the main body
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace function
{
class Program
{
// create a function
void display()
{
Console.WriteLine("welcome");
}
static void Main(string[] args)
{
}
}
}
*How to access function():-
-In javascript function is aaccess using button control with on click event
-In c# access all the function using object
-All object is to be created inside the main body
Syntax:-
className objectName = new className();
-new is called allocation operator
*Access function with object:-
-Access all function with object using dot(.) operator
- dot is called member access operator
-Syntax:-
objectName.functionName();
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace function
{
class Program
{
// create a function
void display()
{
Console.WriteLine("welcome Nagpur");
}
static void Main(string[] args)
{
//create object
Program p1 = new Program();
p1.display();
Console.ReadKey();
}
}
}
Comments
Post a Comment