Tuesday, 2024-12-24, 11:10 PM
Welcome Guest | RSS
Site menu
Tag Board
500
Our poll
How is .Net classes by R.N.Reddy sir ?
Total of answers: 243
Statistics

Total online: 2
Guests: 2
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
 
«  December 2024  »
SuMoTuWeThFrSa
1234567
891011121314
15161718192021
22232425262728
293031

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