Showing posts with label Casting. Show all posts
Showing posts with label Casting. Show all posts

Tuesday, June 21, 2011

OOPs Concept

Object Oriented Programing is common practice in modern software development. So any beginner developer  must know what it is and should be able to explain certain terms which  is  used in .NET a object oriented programming  platform .  
  • Classes
  • Properties
  • Methods
  • Fields
  • Members
  • Enums
  • Casting
  • Structures
  • Abstraction
  • Encapsulation
  • Interfaces
  • Static classes
  • Constructors
  • Method overloading
  • Inheritance
  • Overriding methods
  • Virtual methods
  • Abstract classes
  • Polymorphism
  • Delegates
  • Events
  • Assemblies
  • Namespaces



Read More.....

Sunday, June 19, 2011

TSQL - Decimal to time

 Yesterday I got one query to change numeric value to decimal value. Suddenly I thought "Are datetime and numeric value convertible?" like It convert in excel. Is it possible SQL Server. After 1 hours searching and trial and error ,  I found result.  
The answer is yes. 
Here are the main rules on DATATIME and NUMERIC value conversions:
  • During the conversion a DATETIME value will be treated as a NUMERIC value with the number of days relative the base date, Jan 1, 1900 being the integer part, and the time of the day being the decimal part.
  • DATETIME values can not be converted to NUMERIC values implicitly using assignment operations.
  • NUMERIC values can be converted to DATETIME values implicitly using assignment operations.
  • DATETIME values and DATETIME values can be converted to each other explicitly using CAST() or CONVERT() functions.
The tutorial exercise below shows you some good examples:
  • Implicit conversion Numeric to Datetime
    Implicit Conversion Numeric To Datetime.

    Implicit Conversion Numeric To Datetime

Saturday, June 18, 2011

As Operator in C#

The as operator is used to perform certain types of conversions between compatible reference types. "As" Operator is also known as a safe cast. What is does is it attempts to cast from one type to another and if the cast fails it returns null instead of throwing an InvalidCastException.
As-casting is equivalent to the following expression except that expression is evaluated only one time.
expression is type ? (type)expression : (type)null