Well done, we had a discussion of the architecture of .NET framework,common language runtime and its building blocks, important namespaces in Framework Class Libraries.
Let me discuss to create simple programs to demonstrate the basics of console,windows,web applications & web services.
Program 1: hello.cs
using System;
class test
{
public static void Main()
{
Console.WriteLine("firs console app");
}
}
.net prompt>> csc hello.cs ---------> which creates hello.exe --> is IL file.
to run... >> hello
to view.. >> ildasm hello.exe ------> This shows the contents of meta-data
Program 2: Multiple source files: hello.cs and app.cs
hello.cs
using System.Windows.Forms;
class test
{
public void m1()
{
MessageBox.Show("Windows Application");}}
app.csusing System;
class app
{
public static void Main()
{
Console.WriteLine("Console Application");
test t = new test(); //object of previous program
t.m1(); //call method of class test
}
}
To compile:>>>> csc *.cs --------> will create app.exe
Program 3: Create a Simple Web application
sample.aspx
-------------------------------> default page language VB.NET
<% response.write("First web app..") %> ---> Store in c:/inetpub/wwwroot (IIS)
-----------------------------> Run in Browser.http://localhost/sample.aspx
Program 4: Create a Simple Web Service
firstws.asmx-------------->Store in c:/inetpub/wwwroot (IIS)
<% @ WebService Language="c#" class="abc" %>--> Test in Browser
using System.Web.Services;
public class abc
{
[WebMethod]
public string m1()
{
return "hello First webservice...";
}
}
http://localhost/firstws.asmx
Hope you got some basic idea about how to create simple programs under .NET.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment