.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Home >> Articles >> C# >> Post New Resource Bookmark and Share   

 Subscribe to Articles

C#.Net Keywords A-E

Posted By:Narayanan       Posted Date: July 30, 2012    Points: 200    Category: C#    URL: http://www.dotnetspark.com  

Keywords are predefined,reserved identifies that have special meanings to the compiler.

Now. we will discuss about the C# Keywords with examples.
1)abstract :
      It can be used with classes,Methods, Properties, Indexers and events,
      Use the abstract modifier in a class declaration to indicate that a class is intended only to be a base class of other classes.

abstract class marks
           abstract public int toalMarks();
        class marksheet :marks
            int mark =0;
            public marksheet (int n)
                mark  =n;
             public override int  toalMarks()
                             return  mark *10;
2)as :
  It is used to perform certaib types of conversion between compatible reference or nullable types.

 class Base
            public override string ToString()
                return  "Gantec";

        class Drved : Base

     private void button1_Click(object sender, EventArgs e)
            Drved dr = new Drved();
            Base bs = dr as Base;
            if(bs!= null)


access members of the base class from within drived class.
 public class EmplyeeDetails
            protected string _employeeName = "Lakshmi Narayanan.S";
           protected int _employeeAge =30;
            public virtual void Getinfor()

                MessageBox.Show("Employee Name:"+  " " + _employeeName);
                MessageBox.Show("Employee Age:" + " " + _employeeAge.ToString());
        public class Employee: EmplyeeDetails
            public string _employeeId="001";
            public override void  Getinfor()
                MessageBox.Show("Employee Id:"  + " " + _employeeId);

    private void button1_Click(object sender, EventArgs e)
            Employee emp = new Employee();

    Used to declare variables to store the Boolean values. true or flase.
  Terminates the closest enclosing loop or switch statement in which it apperars,
  break statement is used to break out of an inner nested loop, and return control to the outer loop.

for loop:
  for (int idx =0;idx <5;idx++)
if (i ==2)

    denotes an integral type that stores values .

7)Case :
  Switch statement is a control statement that selects a switch section to execute form a list of candidates.
private void displayvalues(string str)
                switch (str)
                    case "pdf":
                    case "PDF":
                        MessageBox.Show("I am PDF reader");
                    case "jpeg":
                    case "JPEG":
                    case "tiff":
                    case "TIFF":
                        MessageBox.Show("I am Image reader");

8) catch :
  try -catch statement consists of a try block followed by one or more catch clauses,which specify handlers for different exceptions.
     It represents a Unicode character.
     unicode charaters are used to represent most of the written lanuages throughout the world.
used to explicitly enable overflow checking for integral-type arithmetic operations and conversions.

     classes are declared using the Keyword class

class base
// Properties,Methods, Fields and So on...

12) Const:
   Modify a declaration od a field or local value.It declares a value of the filed or the local variable is constant ,which means it cannot be modified.
    Passes control to the next iteration of the enclosing interation statement in which it appears.
more precision and a smaller range, which makes it appropriate for financial and monetary calculations.
      used ot switch case or generic code.

     delegate  has a return value and any number of paramenters of any type.
     delegate is a type safe and secure.
    executes a statement or a block of statements.
18) double:
              Simple type that stores 64bit floating point value.
19) else:
          if statement selects a statement for execution based on the values of a Boolean expression.
    enum keyword is used to declare an enumaration
    constants value shouldnot be duplicate values in the enumerator list.
21) event:
   declare an event in a publisher class.
22) explicit:
       declare a user defined type conversion operator that must be invoked with a case.
       The conversion operator converts from a source type to a target type.
23) extern :
with the DllImport attribute when you are using Interop services to call into unmanaged code.

 Subscribe to Articles


Further Readings:


No response found. Be the first to respond this post

Post Comment

You must Sign In To post reply
Find More Articles on C#, ASP.Net, Vb.Net, SQL Server and more Here

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend