blob: c6e2a95745c0bda3c2dc913ab5456cec05ba5203 (
plain)
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
44
45
|
//
// This test excercises user defined conversions and an implicit
// conversion to a type afterwards.
//
//
using System;
class Blah {
public static int Main ()
{
Blah k = new Blah ();
float f = k;
if (f == 2){
Console.WriteLine ("Best implicit operator selected correctly");
return 0;
}
return 1;
}
public static implicit operator byte (Blah i)
{
Console.WriteLine ("Blah->byte");
return 0;
}
public static implicit operator short (Blah i)
{
Console.WriteLine ("Blah->short");
return 1;
}
public static implicit operator int (Blah i)
{
Console.WriteLine ("Blah->int");
return 2;
}
}
|