blob: b7e219b53afc2f044c02df2a247ff8d5651fd505 (
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
|
class Test
{
public static T QueryInterface<T>(object val)
where T : class
{
if (val == null)
return null;
// First, see if the given object can be directly cast
// to the requested type. This will be a common case,
// especially when checking for standard behavior interface
// implementations (like IXrcDataElement).
T tval = val as T;
if (tval != null)
return tval;
// ... rest of method unimportant and omitted ...
return null;
}
}
class Driver
{
public static void Main () {}
}
|