Saturday, 2024-04-27, 11:41 PM
Welcome Guest | RSS
Site menu
Tag Board
500
Our poll
Rate my site
Total of answers: 148
Statistics

Total online: 1
Guests: 1
Users: 0

17-12-2010 >>>>>>>>>>>>>>>>>>>>>>>>>>>>>

1. C++ Style of type casting:

Syntax: <Todatatype> <Tovariable> = <(Todatatype)> <From variable>;

Eg: for C++ style of type casting:
    Void main()
    {
      int i = 30;
      Byte b = (Byte) i;
      Console.WriteLine("b value is " +b);
      Console.ReadLine();
    }

Parasing: In parasing, we will use a predefined method called Parse().

Parse is a member method of every data type, predefined structure like below:

Struct int            Struct Long
{                       {
  Parse()              Parse()
  {                        {
   }                       }
}                       }

Parse method will accept input as one argument that is also string only.

Using parse method we can convert from string data type to any other data type.

Syntax: <To datatype> <To Variable> = <To datatype>.Parse(<String>);

Eg: for parsing:
    Void main()
    {
      Console.WriteLine("Enter your age: ");
      int age = int.parse(Console.ReadLine());
      Console.WriteLine("Your age is " +age);
      Console.ReadLine();
    }
Output: Enter your age
              300
             Your age is 300

Drawback: Using parsing we can convert from only string to any other data type that means parse method will accept input as only strings.

3. Converting: In converting we will use a predefined class called convert.

Convert class will have various data type conversion methods like below:

Class Convert
{
Toint16()        Tosingle()
  {                    {
  }                    }
Toint32()        Todouble()
  {                    {
  }                    }
Toint64()        Tostring()
  {                    {
  }                    }

}

Using converting we can convert from any data type to any other data type.

Syntax:
<To datatype> <To variable> = Convert.<Conversion method>(<from variable>);

Eg: for converting:

    Void main()
    {
      Console.WriteLine("Enter first number");
      int a = Convert.Toint32(Console.ReadLine());
      Console.WriteLine("Enter second number");
      int b = convert.Toint32(Console.ReadLine());
      int c = a + b;
      Console.WriteLine("C value is " +c);
      Console.ReadLine();
    }
Output: Enter first number
             10
             Enter second number
             5
            C value is 15

Boxing & Unboxing:

1. Boxing: Boxing is a process of converting from value type to reference type.

Eg: From int to object:

2. Un-Boxing: Unboxing is a process of converting from reference type to value type.

Eg: From object to int.

Synatx:
<To datatype> <Tovariable> = <(To datatype)> <from variable>

Ex: For boxing & unboxing:
    Void main()
    {
    int i = 25;
    object obj = (object) i; // Boxing
    Console.WriteLine("Obj value is " +obj);
    int j = (int) obj; // Unboxing
    Console.WriteLine("j value is " +j);
    Consloe.ReadLine();
    }
Output: obj value is 25
              j value is 25



OBJECT ORIENTED PROGRAMMING CONCEPTS (OOPS):

    1. Class & Object

    2. Abstraction

    3. Encapsulation

    4. Inheritance

    5. Polymorphism

1. Class & Object: Class is a collection of members, it can contain variables, properties, methods, constructors, destructors, events & indexers & So on..

Syntax: To declare a class
    <Access modifier> class <class name>
    {
    <Variables>;
    <Properties>;
    <Methods>;
    <Constructors>;
    <Destructors>;
    <Events>;
    <Indexers>;
    }



Search

Time
 

 

Calendar
 
«  April 2024  »
SuMoTuWeThFrSa
 123456
78910111213
14151617181920
21222324252627
282930

Twitter
 

Entries archive

Copyright R N Reddy © 2024Developed by Nagendra, Venkat, Vijaya and Yaswanth
Get free updates as SMS to your mobile. Just register by clicking here