...
. . .
-
2008
...
.., ..
-
-
...
2008
681.3
. ., ...: - : . : - . . . -, 2008. 100 .
ISBN
- Visual C#.NET. - Visual C#.NET.
. 1. . 5. .: 3 .
:
ISBN - . . . -, 2008
. ., .. 2008
1
.
-
C# ++. - ++. ++ # - . - . . , (). . # . . # Main() ( ).
:
lass _
{
//
}
. , . Microsoft Visual Studio.NET , . Microsoft Visual Studio.NET . File|New|Project. New Project Visual C# Projects - Console Application. (Name) , , . (Location) , :
|
|
C:\work\4255
.
, :
using System;
namespace ConsoleApplication10
{
/// <summary>
/// Summary description for Class1.
/// </summary>
class Class1
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main(string[] args)
{
//
// TODO: Add code to start application here
//
}
}
}
using System;, using, , (), . , , System, .NET.
namespace ConsoleApplication10 . . , . .
, , , , .
, .
C# :
- (/**/)
- (//)
- XML (///) .
[STAThread] . . , , . Main.
:
static void Main(string[] args)
Main (static) void. Main() C# main() . - , . , , :
// TODO: Add code to start application here
:
static void Main(string[] args)
{
//
// TODO: Add code to start application here
Console.WriteLine("!");
//
}
, . Debug | Start Without Debugging Ctrl+F5. .
, , , :
Console.WriteLine("!");,
.
- Console .NET.
Console.ReadLine(), Console.Read().
|
|
:
- Console.Write(), , ,
- Console.WriteLine(), , Console.Write(), .
Main() , :
static void Main(string[] args)
{
// TODO: Add code to start application here
Console.WriteLine(" ");
string str=Console.ReadLine();
Console.WriteLine(" "+str+"!!!");
Console.WriteLine(" ");
int kod=Console.Read();
char sim=(char)kod;
Console.WriteLine(" "+sim+" = "+kod);
}
.
Main() .
, Console.WriteLine , +.
, Console.WriteLine, ( ), printf() . , . . .
, , .
static void Main(string[] args)
{
// TODO: Add code to start application here
Console.WriteLine(" ");
string str=Console.ReadLine();
Console.WriteLine(" "+str+"!!!");
Console.WriteLine(" ");
int kod=Console.Read();
char sim=(char)kod;
Console.WriteLine(" "+sim+" = "+kod);
Console.WriteLine(" {0} = {1}",sim,kod);
}
. , .
, . , {1,3} , . , , , .
4 Main(), :
static void Main(string[] args)
{
Console.WriteLine(" ");
string str=Console.ReadLine();
Console.WriteLine(" "+str+"!!!");
Console.WriteLine(" ");
int kod=Console.Read();
char sim=(char)kod;
Console.WriteLine(" "+sim+" = "+kod);
Console.WriteLine(" {0} = {1}",sim,kod);
int s1=255;
int s2=32;
Console.WriteLine(" \n{0,5}\n+{1,4}\n-----\n{2,5}",s1,s2,s1+s2);
Console.WriteLine(" \n{1,5}\n+{0,4}\n-----\n{2,5}",s1,s2,s1+s2);
}
, , .
8 :
,
D ,
E () ,
F ,
G ,
N ,
P ,
X
, {2,9:C2} , , 9 . . .
Main(), :
|
|
static void Main(string[] args)
{
// TODO: Add code to start application here
Console.WriteLine(" ");
string str=Console.ReadLine();
Console.WriteLine(" "+str+"!!!");
Console.WriteLine(" ");
int kod=Console.Read();
char sim=(char)kod;
Console.WriteLine(" "+sim+" = "+kod);
Console.WriteLine(" {0} = {1}",sim,kod);
int s1=255;
int s2=32;
Console.WriteLine(" \n{0,5}\n+{1,4}\n-----\n{2,5}",s1,s2,s1+s2);
Console.WriteLine(" \n{1,5}\n+{0,4}\n-----\n{2,5}",s1,s2,s1+s2);
double sum1=500.3467;
double sum2=43.5;
Console.WriteLine(" \n{0,10:C2}\n+{1,9:C2}\n-----\n{2,10:C2}",
sum1,sum2,sum1+sum2);
}
.
, , .
:
1. Console, ?
2. Read()?
3. ReadLine()?
4. Console, ?
5. , +?
6. , {}, Console.WriteLine(" {0} = {1}",sim,kod);?
7. {} Console.WriteLine, ?
8. ?
9. , ?
10. ? ?
11. ?
:
0 180 10 . Math. , , :
, 4 .
, .
, .
1. F(x)=sin(x);
2. F(x)=cos(x);
3. F(x)= sin(x)+cos(x);
4. F(x)= tg(x);
5. F(x)=ctg(x);
6. F(x)=sinh(x);
7. F(x)=cosh(x);
8. F(x)= sinh(x)+cosh(x);
9. F(x)= tgh(x);
10. F(x)=ctgh(x);
2
,
, ().
. .
:
lass _
{
//
}
.
, , .
() new:
_ _ = new _();
. :
|
|
- public .
- private .
- protected , .
- internal .
private. , private, .
, .
-, .
, , , :
class CA
{
public int x;
protected float z;
double m;
public char sim;
private decimal sum;
}
, , m .
, const, , , , :
public const int x = 25;
, , - . .
.
, . , . - .
, , ref out. , , . . ref, out, ref . ref out . static :
public static int minabs(ref int x,ref int y)
{
//
}
, , :
Cmin.minabs(ref a,ref b);
# ( Cmin).
, 1.
.
1:
using System;
namespace ConsoleApplication12
{
class Cmin
{
public static int min(int x,int y)
{
int z = (x<y)?x:y;
return z;
}
public static int minabs(ref int x,ref int y)
{
x = (x<0)?-x:x;
y = (y<0)?-y:y;
int z = (x<y)?x:y;
return z;
}
}
class Class1
{
[STAThread]
static void Main(string[] args)
{
int a=-4;
int b=2;
Console.WriteLine("a={0} b={1}",a,b);
int k =Cmin.min(a,b);
Console.WriteLine("a={0} b={1}",a,b);
Console.WriteLine("k="+k);
k =Cmin.minabs(ref a,ref b);
Console.WriteLine("a={0} b={1}",a,b);
Console.WriteLine("k="+k);
}
}
}
# - .
- (get) (set).
, y, m, :
private int m=35;
public int y
{
get
{
return m;
}
set
{
m=value;
}
}
, , , , get set. , . get , . set value, . , .
.
2:
using System;
namespace ConsoleApplication11
{
class CStatic
{
private int m=35;
public int y
{
get
{
return m;
}
set
{
m=value;
}
}
}
class Class1
|
|
{
[STAThread]
static void Main(string[] args)
{
// TODO: Add code to start application here
CStatic p=new CStatic();//
Console.WriteLine("{0}",p.y);
p.y=75;
int z = p.y;
Console.WriteLine("{0}",z);
}
}
}
2, .
, . , . , this.
3:
using System;
namespace ConsoleApplication13
{
class Rmas
{
protected float[] msf=new float[10];
public float this[int j]
{
get
{
return msf[j];
}
set
{
msf[j]=value;
}
}
}
class Class1
{
static void Main(string[] args)
{
Rmas obj = new Rmas();
for(int i=0; i<10;i++)
{
obj[i] = (float)1.5*i;
}
for(int i=0; i<10;i++)
{
Console.WriteLine("{0}",obj[i]);
}
}
}
}
:
1. ?
2. ?
3. ?
4. private protected?
5. , ?
6. , ?
7. ref out?
8. ?
9. ?
10. ?
11. ?
12. , , ?
13. ?
:
1. 1,2.3, .
2. , , , . . . . . .
3. , , , . . . . .
4. , 5, , , . . . . , .
5. , 5, , , - . . . . , - .
6. , 5, , , . , . . . . , .
7. , 5, , , . , . . . . , .
8. , 5, . . . . .
9. , 10, . . . . .
10. , 5, . . . . .
3