473,473 Members | 1,870 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

A simple Console Application to ASP.NET application

I am trying to convert Simpson integration algorithm given in the second section of http://csharpcomputing.com/Tutorials/Lesson16.htm

from Console App to an ASP.NET 2.0 page.

Here is the code
<script runat="server">

protected void Page_Load(object sender, EventArgs e){

class Integral{

public delegate double Function(double x);

public static double integral(Function f, double a, double b, int step_number){

double sum = 0;

double step_size = (b - a) / step_number;
for (int i = 0; i < step_number; i = i + 2)
sum = sum + step_size / 3 *(f(a + i * step_size) + 4 * f(a + (i + 1) * step_size) + f(a + (i + 2) * step_size));

return sum;

}

}

class Test{

//a simple function to be integrated

public static double f1(double x){

return (x * x);

}

Response.Write((Integral.integral(new Integral.Function(f1), 1, 10, 20)).ToString).;

}

}

</script>

I tried other way but erred. As beginner, I do not know what is wrong.

Jan 27 '06 #1
1 1294
You can try the following in the code behind model, I'm not sure how to write
it as inline script. I think part of the problem was trying to declare the
class inside the Page_Load event handler. Since the Response.Write(...) line
replaces the Console.WriteLine(...) code from the example, you should just
keep the f1 definition in the same class. Hope that helps - Chase

protected void Page_Load(object sender, EventArgs e)
{
Response.Write((Integral.integral(new Integral.Function(f1), 1, 10,
20)).ToString());
}

public static double f1(double x)
{
return (x * x);
}
class Integral
{

public delegate double Function(double x);

public static double integral(Function f, double a, double b, int
step_number)
{

double sum = 0;

double step_size = (b - a) / step_number;
for (int i = 0; i < step_number; i = i + 2)
sum = sum + step_size / 3 *(f(a + i * step_size) + 4 * f(a + (i + 1)
* step_size) + f(a + (i + 2) * step_size));

return sum;

}

}

"Web learner" wrote:
I am trying to convert Simpson integration algorithm given in the second section of http://csharpcomputing.com/Tutorials/Lesson16.htm

from Console App to an ASP.NET 2.0 page.

Here is the code
<script runat="server">

protected void Page_Load(object sender, EventArgs e){

class Integral{

public delegate double Function(double x);

public static double integral(Function f, double a, double b, int step_number){

double sum = 0;

double step_size = (b - a) / step_number;
for (int i = 0; i < step_number; i = i + 2)
sum = sum + step_size / 3 *(f(a + i * step_size) + 4 * f(a + (i + 1) * step_size) + f(a + (i + 2) * step_size));

return sum;

}

}

class Test{

//a simple function to be integrated

public static double f1(double x){

return (x * x);

}

Response.Write((Integral.integral(new Integral.Function(f1), 1, 10, 20)).ToString).;

}

}

</script>

I tried other way but erred. As beginner, I do not know what is wrong

Jan 27 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: savvy | last post by:
i'm trying to compile a simple console application for sending a mail, my main idea is to schedule it to a particular time for sending mails using the windows schedular task lateron. Therefore i...
3
by: billr | last post by:
Excuse me if you consider this a cross post, however, it was originally destined for this group not the vc.atl group, but somehow it went there instead of here! (obviously it was something I did, but...
7
by: abcd | last post by:
I am trying to set up client machine and investigatging which .net components are missing to run aspx page. I have a simple aspx page which just has "hello world" printed.... When I request...
1
by: lucifer | last post by:
hi, i am creating an simple http server ie it serves only static pages . u can compile the code then use ur browser if it is IE then the it shows the page but the http header is also shown...
2
by: lucifer | last post by:
hi, i am creating an simple http server ie it serves only static pages . u can compile the code then use ur browser if it is IE then the it shows the page but the http header is also shown...
6
by: academic | last post by:
I want to compile a simple c program. Not c++ Not even Windows. Just a simple program to run in a DOS window. In vs2005 what type of project to I use. I can't get started. I tried a couple...
4
by: garyusenet | last post by:
Hi. I am trying to learn about array lists, and found an example on MSDN. I tried to compile it but it's not producing any output. I can't see why. Any ideas? Here is what I did. 1....
4
by: =?Utf-8?B?Y2FsZGVyYXJh?= | last post by:
Dear all, Until now I was programing for more that 6 years using VB.net simply because I come from that word and used to. Now I need to switch to C# simply because my customer want its project...
0
by: myself337 | last post by:
in VB you can do this: Imports System Imports System.IO Module Module1 Sub Main() Dim path As String = "c:\temp\filetocopy.txt" ' put the file you
4
by: Axel Dahmen | last post by:
Hi, I've created a few simple console tools. No .NET used at all, just STL. Now I want to just XCOPY them to another machine. But running them there yields a couple of errors in the application...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.