ads

Sunday, September 16, 2007

C# Link Generate to HTML Code

Here is a sample program where user can generate HTML Link code just by inputing the address and description of the Site.. then the application will automatically generate the code

screen shot
Source Code:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace Link
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
String linkname = "", linksite = "", linkdesc = "", linkResult;
linkname = textBox1.Text;
linksite = textBox2.Text;
linkdesc = textBox3.Text;
string link = "" + linkname + "";
if (textBox4.Text != "" )
{
textBox4.Text += "
" + link;
}
else
{
textBox4.Text = link;
}
}
private void button2_Click(object sender, EventArgs e)
{
textBox4.SelectAll();
textBox4.Copy();
}
private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
{
WebBrowser web = new WebBrowser();
linkLabel1.Text = SiteAdvertise(1);
web.Navigate("http://zoul1380.blogspot.com","_new");
}
}
}

Monday, September 3, 2007

C# Sample Code : Exercise Palindrome

Filename: Program.CS



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

namespace Exercise_02___Palindromes
{
class Program
{
//string aword;

static void Main(string[] args)
{
bool wResult;

Console.WriteLine("Palindrome Checker");


for (int x = 0; x < 20; x++)
{
Console.Write("=");
}
Console.WriteLine();
Console.Write("Input String : ");
string aword = Console.ReadLine();

clsCheckWord CheckWord = new clsCheckWord();

CheckWord.Givenword = aword;
int ix = CheckWord.isPalindrome();

if (ix == 1)
{
Console.Write("Result : A Valid Palindrome");
}
else
{
Console.Write("Result : Not A Palindrome");
}

Console.ReadLine();
}
}
}




Class Filename : clsCheckWord.cs




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

namespace Exercise_02___Palindromes
{
class clsCheckWord
{
public clsCheckWord(){}

public string givenword="";

public string Givenword
{
get { return givenword; }
set { givenword = value; }
}

public int isPalindrome()
{
string tmpcomp="";

for (int x = 0; x < givenword.Length; x++)
{
tmpcomp = givenword.Substring(x, 1) + tmpcomp;
}

if (tmpcomp == givenword)
{
return 1;
}
else
{
return 0;
}
}
}
}

Google Search