why only Pascale calling method in .net language? as in c language we can use both Pascal calling and cdecl calling
In Pascal calling we pass values from left to right
and in cdecl calling we pass values from right to left
Loading
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
VulpesPosted Jan 4, 2013, 4:19 PM
shrikant mulePosted Jan 4, 2013, 3:05 PM
VulpesPosted Jan 4, 2013, 9:31 AM
When the method is called, the arguments will be popped from the stack and will therefore be passed to the method from right to left. The last one popped will, of course, be the hidden first argument which is the instance pointer, as we're using an instance method.
The equivalent C program:
works differently to this even though the arguments are still passed from right to left.
Worse still, the results appear to be compiler dependent because in Visual C (I don't have Turbo C) it produces the output:
6 5
7
and not:
7 5
7
Evidently the arguments are evaluated in the order they are passed rather than the order they're written,
So, in Turbo C, the second argument (a++) is passed as 5 (the current value of 'a'), immediately incremented to 6 and then to 7 (++a) which is passed as the first argument.
In Visual C, it appears that the first increment (a++) is postponed until after the second argument has been evaluated and passed.
In fact, it is definitely the case that the postfix and prefix increment (and decrement) operators are not implemented in exactly the same way in C# as they are in C. See, for example, this thread and the post by compiler expert, Eric Lippert, who was until recently a member of the C# team:
http://stackoverflow.com/questions/3346450/what-is-the-difference-between-i-and-i
shrikant mulePosted Jan 4, 2013, 2:07 AM
VulpesPosted Dec 25, 2012, 7:08 AM