0

Suppose i have a javascript

<script language="javascript">

var Calculator =function ADD(int x,int y)
                {
                  return x+y;
                }

</script>

(1) using dynamic keyword how can i access the "ADD()" and pass parameters?

(2) Do i need to refer any namespace in order to achieve it?

2
  • 1
    Can you explain a little more about what you're trying to do? Commented Apr 12, 2010 at 18:38
  • Lot of videos showing some calculator demo! But I did not get it Commented Apr 12, 2010 at 18:41

1 Answer 1

1

I think you are mixing up languages.

The dynamic keyword is in C#. You'll need to pass the C# variable values to the browser if you want JavaScript to add the numbers. If you want to add in javascript you have to do something like:

<script language = "JavaScript" >

var Calculator =function ADD(int x,int y)
                {
                  return x+y;
                }


 Calculator('<%=Value1.ToString()%>', '<%=Value2.ToString()%>');

</script>

This is assuming Value1 and Value2 are numbers (int, short etc.);

http://www.hanselman.com/blog/C4AndTheDynamicKeywordWhirlwindTourAroundNET4AndVisualStudio2010Beta1.aspx

Looking at the blog entry, you can do it if there is a .net implementation of the language (like python) using the dynamic keyword.

EDIT: Here is a link to the CodePlex project to put a JavaScript implementation on top of the DLR.

http://javascript.codeplex.com/

With this, using the dynamic keyword should be possible.

Sign up to request clarification or add additional context in comments.

3 Comments

I thought ,I can call this Calculator object from my C# dynamic keyword
No not if the Calculator object is written in JavaScript.
Now,I can understand the real use of Dynamic

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.