Csharp/C Sharp/Language Basics/Expressions — различия между версиями
Admin (обсуждение | вклад) м (1 версия) |
Admin (обсуждение | вклад) м (1 версия) |
(нет различий)
|
Текущая версия на 11:39, 26 мая 2010
Expressions 1
/*
* C# Programmers Pocket Consultant
* Author: Gregory S. MacBeth
* Email: gmacbeth@comporium.net
* Create Date: June 27, 2003
* Last Modified Date:
* Version: 1
*/
using System;
namespace Client.Chapter_2___Operators_and_Excpressions
{
public class Expressions
{
static void Main(string[] args)
{
int MyInt = 12345;
int MyInt2 = 10000;
int Sum = 0;
long MyLong = MyInt;
short MyShort = (short)MyInt;
if (MyInt == MyInt2)
{
Sum = MyInt + MyInt2;
}
else
{
Sum = MyInt - MyInt2;
}
}
}
}
Expressions to calculate and display the circumference of a circle
/*
Mastering Visual C# .NET
by Jason Price, Mike Gunderloy
Publisher: Sybex;
ISBN: 0782129110
*/
/*
Example3_1.cs illustrates the use of
expressions to calculate and display
the circumference of a circle
*/
public class Example3_1
{
public static void Main()
{
const double Pi = 3.14159;
double diameter = 2.5;
// calculate the circumference
double circumference = Pi * diameter;
// display the circumference
System.Console.WriteLine("Circumference = " + circumference);
}
}