forked from idg10/prog-cs-8-examples
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathProgram.cs
43 lines (38 loc) · 1.23 KB
/
Program.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
using System.Numerics;
using System.Reflection;
namespace Arrays
{
class Program
{
static void Main()
{
int[] numbers = new int[10];
string[] strings = new string[numbers.Length];
// Continued from Example 5-1
numbers[0] = 42;
numbers[1] = numbers.Length;
numbers[2] = numbers[0] + numbers[1];
numbers[numbers.Length - 1] = 99;
var values = new Complex[10];
values[0] = new Complex(10, 1);
}
public static string GetCopyrightForType(object o)
{
Assembly asm = o.GetType().Assembly;
var copyrightAttribute = (AssemblyCopyrightAttribute)
asm.GetCustomAttributes(typeof(AssemblyCopyrightAttribute), true)[0];
return copyrightAttribute.Copyright;
}
// This example shows something illegal. Change the #if false to #if true
// to see the complier error.
#if false
private static void IllegalImmutableValueUse()
{
var values = new Complex[10];
// These lines both cause compiler errors:
values[0].Real = 10;
values[0].Imaginary = 1;
}
#endif
}
}