Showing posts with label C#. Show all posts
Showing posts with label C#. Show all posts

Tuesday, October 30, 2007

HTML Templates

In this tutorial, I'll provide the basic html codes used in website designs. In web application development most developers use WYSIWYG (What You See Is What You Get) type programs like Frontpage, Dreamveawer and Visual Studio. But if you want to take advanced control of your website, sticking to the html codes is inevitable and most developers directly work on the html tags. Let's not forget to say HTML stand for "Hyper-Text Markup Language".



Let's take a look at how the html structure of a web page is:
<html>
<head><title>New Page</title></head>
<body>
</body>
</html>


Above is the html template code that has to be present in EVERY html page so that it can be displayed by the browsers like Firefox, Internet Explorer, Netscape etc. Notice that this script is well-formed i.e. each tag has a matching closing tag.

There are two major code manipulations to make a web page work.
  1. Javascript
  2. CSS
Javascript, in a nutshell, is a client-side scripting language. I'll tell what this means in just a moment.
CSS stands for "Cascading Style Sheets". As it's name implies, it is used to manipulate the style, look and feel of a web page.

In addition to these two code manipulations, you need to deal with a third type of code which is server side scripting and programming if you need a dynamic page. C#, VB.NET, PHP, ASP CGI are examples of server side programming.
Here comes the difference between Javascript and C#. One is client side coding and the other one is server side coding. For instance C# runs and processes the user input in the server and responds to a users request while Javascript runs in the users computer and validates user input or triggers some funny effects when the users moves their mouse.

We will code html template with more functionalities in the next posts. So bear with me and feel free to share your comments.

Friday, April 27, 2007

C# programming notes



  • Two references to the same object--Interesting!!!



Source: C# 2005 for Dummies, Wiley.

Tuesday, April 17, 2007

1. Interest Calculation

This is the first Console program I have written in the C# & .NET class:

Program.cs


using System;
using System.Collections.Generic;
using System.Text;


namespace Interest
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Enter the money (p):");
int p = int.Parse(Console.ReadLine());
Console.WriteLine("Enter the rate of interest (R):");
double R = double.Parse(Console.ReadLine());
Console.WriteLine("Enter the time (T):");
int T = int.Parse(Console.ReadLine());

InterestCalc IC = new InterestCalc();
Console.WriteLine("Simple Interest:");
Console.WriteLine(IC.CalculateSimpleInterest(p, R, T));
Console.WriteLine("Compound Interest:");
Console.WriteLine(IC.CalculateCompoundInterest(p, R, T));
Console.Read();
}
}
}




InterestFunctions.cs



using System;
using System.Collections.Generic;
using System.Text;

namespace Interest
{
class InterestCalc
{
public InterestCalc()
{
}

public double CalculateSimpleInterest(int p, double r, int t)
{
return (p*r*t)/100;
}

public double CalculateCompoundInterest(int p, double r, int t)
{
return p*(1+r/100)*t;
}
}
}




WHAT I HAVE LEARNED?

The organization of the codes in C# consists of two main code blocks:

  1. namespace
  2. class
namespaces can include different classes. We can place the codes of each of the classes in different files.
-In this example, the class including the main program is named class Program{} and saved in Program.cs file.
-On the other hand, the second class including the functions for the interest calculation is named class InterestFunctions{} and is saved in InterestFunctions.cs file.

Both classes are implemented under the SAME namespace called namespace Interest{}.