.
:
1.
2.
3.
4. ,
5.
<>_ ()
{
< > +
}
. .
, .
3 :
1. ( )
:
1. ( ) . . .
2. , . , .. . out.
3. - , . ref.
.
. return ;
.
, .. :
1. (, ..)
2.
3.
.
:
, .
class_Example
{
public_static_void_Mov (ref int x, ref int y, int d)
{
x=x+d;
y=y+d;
}
public_static_void_Main()
{
int a=4, b=3, d=10;
Move (ref a, ref b, d);
}
}
Main()
. , .
|
|
, . Main() , .
. , .
C:\PR\PR\BIN\DEBUG\pr.exe_1_ 2_... _N
Main : Main (string[] args)
. .
, .
Plus
Minus
pr.exe.
1.
2.
( ) +
( )
3. ()
C:\PR\PR\BIN\DEBUG\ pr.exe_50__
args Main()
public static void Plus(double[] p, double s)
// , ,
{
for (int i = 0; i < p.Length; i++)
p[i] += s;
}
public static void Minus(double[] p, double s)
{
for (int i = 0; i < p.Length; i++)
p[i] -= s;
}
public static Main(string[] args)
{
double[] pr; //
double delta; //
string key = ""; //
pr = new double[] { 100.0, 200.0, 300.0 };
//
if (args.Length!= 3) return;
// - 1
//
if (args[2]!= key) return;
// - 2
//
delta = double.Parse(args[0]);
//
switch (args[1].ToUpper())
{
case "":
case "+": Plus(pr, delta); break;
case "":
case "-": Minus(pr, delta); break;
}
//
return;
}
, , , . .
, -.
, , :
1. , , .
2. , , ,
3. , .
.
|
|
, , .
, , .
,
:
public void Caller()
{
int numA = 4;
int numB = 32;
int productA = Square(numA);
int productB = Square(numB);
int productC = Square(12);
productC = Square(productA * 3);
}
int Square(int i)
{
int input = i;
return input * input;
}
out
class OutExample
{
static void Method(out int i)
{
i = 44;
}
static void Main()
{
int value;
Method(out value); }}