Month: August 2014

Pivot table and Find DateDifference in fomat of Number of year,Month and Days in sql server

—-Use of datedifference Declare @PreviousDate datetime=‘2001-11-08’; Declare @CurrentDate date=CONVERT(date,GETDATE(),110); Declare @CurrentDate1 date=CONVERT(varchar(10),GETDATE(),110); declare @datediff int=DATEDIFF(DAY,@PreviousDate,@CurrentDate); Declare @NumLeapYear INT=DATEDIFF(YEAR,@PreviousDate,@CurrentDate)/4 –for Count of Leap Year but may be some extend to be need.; with FindDate as(Select @datediff as TotalDays, (   @datediff % 365)as NumMonth,–for calculate of MonthCount @CurrentDate as TodayDate,@CurrentDate1 as TodayDate1 ) Select   TotalDays/365 asYear, NumMonth /31 asMonth, (((NumMonth/31)%31)+@NumLeapYear)asdays,TotalDays… Read more →

Dictionary ,Hashtable and HashSet

HashTable Represents a collection of key/value pairs that are organized based on the hash code of the key. Hashtable optimizes lookups. It computes an adding hash of each key. It then uses this hash code to look up the element very quickly. It is an older .NET Framework type. It is slower than the generic Dictionary type. Dictionary A dictionary… Read more →

Typeof operator,GetType method,as operator & Is operator

—Typeof operator and GetType Method Used to obtain the System.Type object for a type. A typeof expression takes the following form: System.Type type = typeof(int); To obtain the run-time type of an expression, we can use the .NET Framework method GetType, as in the following example: int i = 0; System.Type type = i.GetType(); The typeof operator cannot be overloaded.… Read more →

Design pattern

What Are Design Patterns and Do I Need Them? Software professionals may be familiar with the term “Design Patterns,” but many have no idea of where they come from and what they truly are. Consequently, some do not see the value and benefits design patterns bring to the software development process, especially in the areas of maintenance and code reuse.… Read more →

Delegate and constructor

Delegate is a reference type that holds the reference of a class method. Any method which has the same signature as delegate can be assigned to delegate. It is very similar to the function pointer but with a difference that delegates are a type-safe. We can say that it is the object-oriented implementation of function pointers. There are three steps… Read more →

Sealed,static and abstract class difference.

Sealed Class A sealed class cannot be used as a base class. Sealed classes are primarily used to prevent derivation. Because they can never be used as a base class, some run-time optimizations can make calling sealed class members slightly faster.   We can also use the sealed modifier on a method or property that overrides a virtual method or… Read more →

Constant,readonly and static discussion

Constant 1)      It is assigned a value at time of declaration but not modified at any time. By default constant is static, hence cannot define as static.const field is a compile time constant. It is fully evaluated at compile time.const keyword to built-in value types (byte, short, int, char, float, decimal etc.), enum, string or reference types which can be… Read more →

Debug and Trace discussion

Debug is used during debugging. Trace is writing to the log file. It is kind of like logging. Both are very similar, but do tracing for long term retention, debugging for real time debugging. When we monitor application execution and performance in development stage is termed as “Debugging” and when you do in deployed environment it’s termed as ‘Tracing’. Debug… Read more →