class:
public class <classname> // class name is user defiend
{
}
{
protected void Page_Load(Object sender,EventArgs e)
{
//Main method for the Program
}
}
public class Doctor
{
public string name="dr.ramesh";
public string address="bangalore";
}
variable:
- class is a user defined data type (or)
- class is a virtual entity (or)
- It is a model or template or blue print
public class <classname> // class name is user defiend
{
}
example:
public partial class _Default:System.Web.UI.Page{
protected void Page_Load(Object sender,EventArgs e)
{
//Main method for the Program
}
}
public class Doctor
{
public string name="dr.ramesh";
public string address="bangalore";
}
variable:
Def:We have to declare a variable when we want to store a data in our program
Variables divided into 2 types 1.Local variables 2.Global variables or Class level variables or Fields. Note:Class level variables are the variables which are directly declared within the scope of the class.
Sample code:
public class Engineer { public int age=36; //Here age is a global variables public string name="Dr.Suresh"; //Here name is a global variables public int M(int x,string y) { int x1=10; //Parameter x and y are local variables string y1="Hello"; return x1; //x1 and y1 declared within M method are local variables } }
No comments:
Post a Comment