locked
What kind technology do I need use based dynamic statement ? RRS feed

  • Question

  • User1040369262 posted

    What kind technology do I need use based dynamic statement in ASP.net with C#?

    I hope the end user input dynamic statement with C# in TextBox1

    For example1
        int i = 5;
        int j = 6;
        int result = i * j - 2;


    For example2
         double d1 = 23.6;
         double  d2= 52.3;
         double result=1.0;
         for (int i = 1; i <= 2; i++)
         {
            result = result * d1 * d2;
         }


    then the result will be displayed when the user click Button1, how can do that? Thanks!

     


    <%@ Page Language="C#" AutoEventWireup="true"  CodeFile="Default.aspx.cs" Inherits="_Default" %>

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

    <html xmlns="http://www.w3.org/1999/xhtml" >
    <head runat="server">
        <title>Untitled Page</title>
    </head>
    <body>
        <form id="form1" runat="server">
        <div>
            Input
            <br />
            <asp:TextBox ID="TextBox1" runat="server" Height="120px" TextMode="MultiLine" Width="192px"></asp:TextBox>
            <br />
            <asp:Button ID="Button1" runat="server" Text="Get Result" /></div>
        </form>
    </body>
    </html>

     


     

    Friday, February 5, 2010 9:15 PM

Answers

  • User1668404196 posted

    Hi Good day, You need to use reflection. Please checkout the below examples

    http://www.codersource.net/csharp_tutorial_reflection.html

    http://www.csharp-examples.net/reflection-examples/

     

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, February 5, 2010 11:50 PM

All replies

  • User1668404196 posted

    Hi Good day, You need to use reflection. Please checkout the below examples

    http://www.codersource.net/csharp_tutorial_reflection.html

    http://www.csharp-examples.net/reflection-examples/

     

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, February 5, 2010 11:50 PM
  • User1040369262 posted

    Will it cause security problem if  I use dynamic compile and run code?

    Thanks!

     

    Tuesday, February 9, 2010 8:20 AM