C# properties: Properties in C# are used to provide protection to the attributes of a class against direct reading or writing to it . By using properties we fix the rule that a particular attribute of the class can be read or written by means of property associated to that attribute.
These can be classified into 3 types:
Read only properties : We implement only the getter in the property implementation.
Syntax:
public String Name { get { return name; } }
Write only properties :We implement only the Setter in the property implementation.
Syntax:
public String Name { set{name=value;} }
Auto implemented properties: This is the most commonly used type. we define the both getter and setter without any actual implementation.
Syntax:
public String Name{get; set;}
Example: Accessing the Employee class with properties
Employee.cs using System; namespace lab1 { public class Employee { private string name; private long empid; public Employee (String Name,long id){ name=Name;empid=id;} public String Name { get { return name; } set{name=value;} } public long Empid { get { return empid; } set{empid=value;} } public override string ToString () { return ("Name:"+name+"\nEmployee ID:"+empid); } } }
Main.cs
using System; using Gtk;
namespace lab1 { class MainClass { public static void Main (string[] args) { Employee E1=new Employee(); E1.Name="kiran"; E1.Empid=1234; Console.WriteLine("Employee details\n {0}", E1); Console.WriteLine("End of Employee details",E1); Console.ReadKey(); } } }
I have been planning to write on this topic for quite some time so finally here it comes.
Before actually trying to publish our website lets understand what this whole process takes.By this I mean that lets first understand the pre requisites for publishing the website and also understand what makes them so very much needed for publishing the website.
The pre requisites are :
A domain name.
The hosting service provider.
Host.
Template.
1. The Domain name: Is basically used to point to a particular IP address . That means it maps or identifies the IP address associated to the name of your website. To understand it better lets take a few examples of the same:
gov
co
co.cc
com
in
net
org
what makes it so important ?
Since it is difficult to remember the IP addresses you need alphabetical name to identify our site and also to let the audience find you on the the internet you need a unique IP address.
2.The Hosting Service provider: Is the service that allows us to publish our web pages online on the internet. To publish the web pages all we need is some space on the server.Don't worry if you want to have this space for free. There are loads of companies which provide you with this server space for free :) .
A website cannot exist without a web space and thus without a webhost, well by this we just answered the question "what makes it so important ?"
3.The host: The application that basically holds the content for our website.Don't worry they are also available for free. An example of this is FileZilla which can be used on Windows, Linux,Mac OS X . You can easily download , install and upload your file to the your server space of your website. Sites like GoDaddy, 000webhost recommend FileZilla.
4. Template: This is all about the look and feel of the website we are trying to create and publish. If you have a good knowledge of Html and CSS you can self code it otherwise you can buy it or even download it for free from some free template providing website.
now lets come to the steps for actually publishing the website that too for free :) .
Step 1: Registering the domain name: Register the domain name.
Step 2:Getting the server space for the website:
Step 3: Getting the template : Buy it or download for free or Code it or download it and make your own edits .
Step 4: Download and install the host and then uploading the files to the server:
/* * To change this template, choose Tools | Templates * and open the template in the editor. */
/* * Login.java * * Created on 23 Jun, 2012, 3:15:08 PM */ package sample; import java.sql.*; import javax.swing.JOptionPane; /** * * @author SunShine */ public class Login extends javax.swing.JFrame {
/** Creates new form Login */ public Login() { initComponents(); }
/** This method is called from within the constructor to * initialize the form. * WARNING: Do NOT modify this code. The content of this method is * always regenerated by the Form Editor. */ @SuppressWarnings("unchecked") // <editor-fold defaultstate="collapsed" desc="Generated Code"> private void initComponents() {
jPanel1 = new javax.swing.JPanel(); jLabel1 = new javax.swing.JLabel(); jLabel2 = new javax.swing.JLabel(); jTextField1 = new javax.swing.JTextField(); jPasswordField1 = new javax.swing.JPasswordField(); jButton1 = new javax.swing.JButton(); jButton2 = new javax.swing.JButton();