dynamic keyword affects return typeWhat is the yield keyword used for in C#?What's the difference between the 'ref' and 'out' keywords?Func delegate with no return typeType Checking: typeof, GetType, or is?Deserialize JSON into C# dynamic object?Dynamic + linq compilation errorDifferent return type for same method of a base classdynamic keyword with ExpandoObject to attach and remove propertiesWhy won't the DLR (dynamic) bind to a private type?What is the difference between .NET Core and .NET Standard Class Library project types?
How do I repair my stair bannister?
Visiting the UK as unmarried couple
anything or something to eat
Did arcade monitors have same pixel aspect ratio as TV sets?
What is the difference between "Do you interest" and "...interested in" something?
Proving a function is onto where f(x)=|x|.
Indicating multiple different modes of speech (fantasy language or telepathy)
Greco-Roman egalitarianism
Reply 'no position' while the job posting is still there
Is a model fitted to data or is data fitted to a model?
What's the difference between 違法 and 不法?
Is camera lens focus an exact point or a range?
Divine apple island
Find last 3 digits of this monster number
Transformation of random variables and joint distributions
Is there a conventional notation or name for the slip angle?
Did US corporations pay demonstrators in the German demonstrations against article 13?
How should I respond when I lied about my education and the company finds out through background check?
Drawing a topological "handle" with Tikz
About a little hole in Z'ha'dum
How to decide convergence of Integrals
How must one send away the mother bird?
Has Darkwing Duck ever met Scrooge McDuck?
What major Native American tribes were around Santa Fe during the late 1850s?
dynamic keyword affects return type
What is the yield keyword used for in C#?What's the difference between the 'ref' and 'out' keywords?Func delegate with no return typeType Checking: typeof, GetType, or is?Deserialize JSON into C# dynamic object?Dynamic + linq compilation errorDifferent return type for same method of a base classdynamic keyword with ExpandoObject to attach and remove propertiesWhy won't the DLR (dynamic) bind to a private type?What is the difference between .NET Core and .NET Standard Class Library project types?
I'm not entirley sure why the following code compiles
namespace ConsoleApp13
public class Person
class Program
static void Main(string[] args)
dynamic expand = new ExpandoObject();
List<Person> people = GetPerson(expand);
public static Person GetPerson(int item)
return new Person();
Why does the dynamic
keyword impact the return type. It's like the compiler give's up on type checking as soon as dynamic
is introduced. Is this expected behavior?
c# .net dynamic .net-core
add a comment |
I'm not entirley sure why the following code compiles
namespace ConsoleApp13
public class Person
class Program
static void Main(string[] args)
dynamic expand = new ExpandoObject();
List<Person> people = GetPerson(expand);
public static Person GetPerson(int item)
return new Person();
Why does the dynamic
keyword impact the return type. It's like the compiler give's up on type checking as soon as dynamic
is introduced. Is this expected behavior?
c# .net dynamic .net-core
add a comment |
I'm not entirley sure why the following code compiles
namespace ConsoleApp13
public class Person
class Program
static void Main(string[] args)
dynamic expand = new ExpandoObject();
List<Person> people = GetPerson(expand);
public static Person GetPerson(int item)
return new Person();
Why does the dynamic
keyword impact the return type. It's like the compiler give's up on type checking as soon as dynamic
is introduced. Is this expected behavior?
c# .net dynamic .net-core
I'm not entirley sure why the following code compiles
namespace ConsoleApp13
public class Person
class Program
static void Main(string[] args)
dynamic expand = new ExpandoObject();
List<Person> people = GetPerson(expand);
public static Person GetPerson(int item)
return new Person();
Why does the dynamic
keyword impact the return type. It's like the compiler give's up on type checking as soon as dynamic
is introduced. Is this expected behavior?
c# .net dynamic .net-core
c# .net dynamic .net-core
edited Mar 21 at 23:43
ArunPratap
2,20621028
2,20621028
asked Mar 21 at 13:45
Steven YatesSteven Yates
1,2081943
1,2081943
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
Is this expected behavior?
Yes. Almost anything you do that involves a dynamic value ends up with a compile-time type of dynamic
. Note that binding is performed dynamically, so even though in this specific case you've only got one GetPerson
method, in the more general case of method invocation, overloads could be present at execution time that aren't present at compile-time, with different return types.
There are a few operations which don't end up with a dynamic type:
- Casting (e.g.
(string) dynamicValue
) - The
is
operator (e.g.dynamicValue is string
) - The
as
operator (e.g.dynamicValue as string
- Constructor calls (e.g.
new Foo(dynamicValue)
)
Thanks! I ended up looking deeper at the IL and then understood what was going on but thank you got the explanation, much appreciated
– Steven Yates
Mar 21 at 16:29
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55281869%2fdynamic-keyword-affects-return-type%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Is this expected behavior?
Yes. Almost anything you do that involves a dynamic value ends up with a compile-time type of dynamic
. Note that binding is performed dynamically, so even though in this specific case you've only got one GetPerson
method, in the more general case of method invocation, overloads could be present at execution time that aren't present at compile-time, with different return types.
There are a few operations which don't end up with a dynamic type:
- Casting (e.g.
(string) dynamicValue
) - The
is
operator (e.g.dynamicValue is string
) - The
as
operator (e.g.dynamicValue as string
- Constructor calls (e.g.
new Foo(dynamicValue)
)
Thanks! I ended up looking deeper at the IL and then understood what was going on but thank you got the explanation, much appreciated
– Steven Yates
Mar 21 at 16:29
add a comment |
Is this expected behavior?
Yes. Almost anything you do that involves a dynamic value ends up with a compile-time type of dynamic
. Note that binding is performed dynamically, so even though in this specific case you've only got one GetPerson
method, in the more general case of method invocation, overloads could be present at execution time that aren't present at compile-time, with different return types.
There are a few operations which don't end up with a dynamic type:
- Casting (e.g.
(string) dynamicValue
) - The
is
operator (e.g.dynamicValue is string
) - The
as
operator (e.g.dynamicValue as string
- Constructor calls (e.g.
new Foo(dynamicValue)
)
Thanks! I ended up looking deeper at the IL and then understood what was going on but thank you got the explanation, much appreciated
– Steven Yates
Mar 21 at 16:29
add a comment |
Is this expected behavior?
Yes. Almost anything you do that involves a dynamic value ends up with a compile-time type of dynamic
. Note that binding is performed dynamically, so even though in this specific case you've only got one GetPerson
method, in the more general case of method invocation, overloads could be present at execution time that aren't present at compile-time, with different return types.
There are a few operations which don't end up with a dynamic type:
- Casting (e.g.
(string) dynamicValue
) - The
is
operator (e.g.dynamicValue is string
) - The
as
operator (e.g.dynamicValue as string
- Constructor calls (e.g.
new Foo(dynamicValue)
)
Is this expected behavior?
Yes. Almost anything you do that involves a dynamic value ends up with a compile-time type of dynamic
. Note that binding is performed dynamically, so even though in this specific case you've only got one GetPerson
method, in the more general case of method invocation, overloads could be present at execution time that aren't present at compile-time, with different return types.
There are a few operations which don't end up with a dynamic type:
- Casting (e.g.
(string) dynamicValue
) - The
is
operator (e.g.dynamicValue is string
) - The
as
operator (e.g.dynamicValue as string
- Constructor calls (e.g.
new Foo(dynamicValue)
)
answered Mar 21 at 13:49
Jon SkeetJon Skeet
1094k69579788464
1094k69579788464
Thanks! I ended up looking deeper at the IL and then understood what was going on but thank you got the explanation, much appreciated
– Steven Yates
Mar 21 at 16:29
add a comment |
Thanks! I ended up looking deeper at the IL and then understood what was going on but thank you got the explanation, much appreciated
– Steven Yates
Mar 21 at 16:29
Thanks! I ended up looking deeper at the IL and then understood what was going on but thank you got the explanation, much appreciated
– Steven Yates
Mar 21 at 16:29
Thanks! I ended up looking deeper at the IL and then understood what was going on but thank you got the explanation, much appreciated
– Steven Yates
Mar 21 at 16:29
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55281869%2fdynamic-keyword-affects-return-type%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown