repo.or.cz
/
mcs.git
/
blob
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
log
|
graphiclog1
|
graphiclog2
|
commit
|
commitdiff
|
tree
|
refs
|
edit
|
fork
blame
|
history
|
raw
|
HEAD
add comment
[mcs.git]
/
tests
/
gtest-anontype-06.cs
blob
cacb85a73140f9a3304128cbeac3b8de4bf146a0
1
2
3
// "cast by example" test
4
5
class
CastByExample
6
{
7
static void
Main
()
8
{
9
object
o
=
new
{ Foo = "Data" }
;
10
// Cast object to anonymous type
11
var
typed
=
Cast
(
o
,
new
{ Foo = "" }
);
12
}
13
14
static
T Cast
<
T
>(
object
obj
,
T type
)
15
{
16
return
(
T
)
obj
;
17
}
18
}