//source code for different function with return
using System;
namespace OOPSProj
{
class Program
{
static void Main(string[] args)
{
Program p = new Program();
p.Test11();
p.Test22(2);
Console.WriteLine(p.Test33());
Console.WriteLine(p.Test44("leejo"));
int b = 0;
int a = p.Test55(100, 50, ref b);
Console.WriteLine(a + " " + b);
Console.ReadLine();
}
//No Input No Output
void Test11()
{
Console.WriteLine("First Method");
}
//No Output Has Input
void Test22(int x)
{
Console.WriteLine("Second Method: " + x);
}
//No Input Has Output
string Test33()
{
return "Third Method";
}
//Has Input & Output
string Test44(string name)
{
return "Hello " + name;
}
//Has Input & Multiple Outputs
int Test55(int x, int y, ref int z)
{
z = x * y;
return x + y;
}
}
}
Showing posts with label c# functions. Show all posts
Showing posts with label c# functions. Show all posts
Sunday, 22 August 2010
source code to return a value
//source code to return a value
using System;
namespace MyCsNsp
{
public class CSTest
{
public string CSMethod()
{
return "Hello from CSharp";
}
}
}
using System;
namespace MyCsNsp
{
public class CSTest
{
public string CSMethod()
{
return "Hello from CSharp";
}
}
}
Labels:
c# functions
different type of function
//different type of function
using System;
namespace AccessDemo1
{
public class Program
{
//private function
private void Test1()
{
Console.WriteLine("Private Method");
}
//internal function
internal void Test2()
{
Console.WriteLine("Internal Method");
}
//protected function
protected void Test3()
{
Console.WriteLine("Protected Method");
}
//protected internal function
protected internal void Test4()
{
Console.WriteLine("Protected Internal Method");
}
//public function
public void Test5()
{
Console.WriteLine("Public Method");
}
static void Main(string[] args)
{
Program p = new Program();
p.Test1(); p.Test2(); p.Test3();
p.Test4(); p.Test5();
Console.ReadLine();
}
}
}
using System;
namespace AccessDemo1
{
public class Program
{
//private function
private void Test1()
{
Console.WriteLine("Private Method");
}
//internal function
internal void Test2()
{
Console.WriteLine("Internal Method");
}
//protected function
protected void Test3()
{
Console.WriteLine("Protected Method");
}
//protected internal function
protected internal void Test4()
{
Console.WriteLine("Protected Internal Method");
}
//public function
public void Test5()
{
Console.WriteLine("Public Method");
}
static void Main(string[] args)
{
Program p = new Program();
p.Test1(); p.Test2(); p.Test3();
p.Test4(); p.Test5();
Console.ReadLine();
}
}
}
Labels:
c# functions
Subscribe to:
Posts (Atom)