| 1 |
public class Student { public int Age; public string FirstName; } |
| 2 |
public class Program { static Student[] students; static void PrintStudent(Student student) { Console.WriteLine("{0,-15}{1}", student.FirstName, student.LastName); } |
| 3 |
static void Main() {} |
| 4 |
students = new[] { new Student { LastName = "Jones", FirstName = "John" }, new Student { LastName = "Williams", FirstName = "William" } }; |
| 5 |
var point = new Point { X = 1, Y = 2 }; point.Print(); Point.PrintPoint(point); |
| 6 |
public static class RandomExtensions { public static double NextDouble(this Random rnd, double min, double max) |
| 7 |
Console.WriteLine(rnd.NextDouble(10, 20)); |
| 8 |
double realNumber = 12.34; |
| 9 |
integerNumber = (int)doubleNumber; |
| 10 |
char = 'e'; |
| 11 |
double number2 = double.Parse("34.42") |
| 12 |
number2 = double.Parse("34.42", CultureInfo.InvariantCulture); |
| 13 |
Console.WriteLine(Math.Sin(angle)); |
| 14 |
var e = a / 2; var f = a / 2.0; |
| 15 |
foreach (var file in directoryInfo.GetFiles()) Console.WriteLine(file.Name); |
| 16 |
string s = "Hello" + " " + "world"; |
| 17 |
char c = myString[1]; |
| 18 |
double number2 = double.Parse("34.42"); |
| 19 |
string numString = 42.ToString(); |
| 20 |
float floatNumber = 1.234f; |
| 21 |
long longIntegerNumber = 3000000000000L; |
| 22 |
integerNumber = (int)Math.Round(34.67); |
| 23 |
if (i < s.Length && s[i] == ' ') |
| 24 |
if (a % 2 == 0) Console.WriteLine("A is even"); |
| 25 |
List<int> list = new List<int>(); list.Add(2); |
| 26 |
var dictionary = new Dictionary<string, int>(); |
| 27 |
foreach (var e in dictionary) |
| 28 |
get {return Math.Sqrt(X * X + Y * Y);} |
| 29 |
public override string ToString() {return string.Format("({0}, {1}) with length: {2}", X, Y, Length);} |
| 30 |
public string Id { get; private set; } |
| 31 |
if (value < 0) throw new ArgumentException(); |
Комментарии