affiliate_link

Friday, April 17, 2009

Stop Youtube from displaying related videos once playback of the initial video starts

To stop displaying related videos we can add a parameter (rel=0 for stop displaying) to the url of the embedded code provided by you tube. See example below

http://www.youtube.com/v/u1zgFlCw8Aw&fs=1&rel=0

For complete list of parameters check the following Google API site:

http://code.google.com/apis/youtube/player_parameters.html

Thursday, April 16, 2009

Finding duplicates with SQL?

Suppose Col1 is the field name for which you want to find duplicates:

Select Col1, Count(Col1) as count
from table1
group by Col1
having Count(Col1) > 1

.

Formatting DateTime to Date in SQL

Select convert(varchar(10),GetDate(),101)

Output: 04/16/2009

Select convert(varchar(10),GetDate(),103)

Output: 16/04/2009

Rounding a number to 2 decimal places in SQL

Use T-SQL Convert Function.

Select convert ( decimal(8,2) , 9.4125 )

Output: 9.41

What is Windows Presentation Foundation (WPF)?

Windows Presentation Foundation (WPF) is a next-generation presentation system for building Windows client applications with visually stunning user experiences. With WPF, you can create a wide range of both standalone and browser-hosted applications. Some examples are Yahoo! Messenger and the New York Times Reader.

The core of WPF is a resolution-independent and vector-based rendering engine that is built to take advantage of modern graphics hardware. WPF extends the core with a comprehensive set of application-development features that include Extensible Application Markup Language (XAML), controls, data binding, layout, 2-D and 3-D graphics, animation, styles, templates, documents, media, text, and typography. WPF is included in the Microsoft .NET Framework, so you can build applications that incorporate other elements of the .NET Framework class library.

Reference: http://msdn.microsoft.com/en-us/library/aa970268.aspx

Wednesday, April 15, 2009

What is LINQ?

Strings act like value types in .Net?

System.String is a reference type in .NET. Don’t let anyone mislead you into thinking otherwise. You’ll hear people saying strings “act like value types”, but this doesn’t mean the runtime makes a copy of the string during assignment operations, and it doesn’t make a copy of a string when passing the string as a parameter.

The equality operator and String.Equals method compare the values of two string objects, and you won’t find a property or method on System.String with the ability to modify the contents of a string – only return a new string object. Because of these two behaviors we sometimes say strings have value type semantics (they feel like value types), but strings are reference types in the runtime. An assignment operation does not copy a string, but assigns a reference. The value given to a string parameter in a method call is the reference, not a copy of the string’s value.

using System;

class Class1

{

[STAThread]

static void Main(string[] args)

{

string s1 = "Hello";

string s2 = s1;

// this test will compare the values of the strings

// result will be TRUE since both s1 and s2

// refer to a string with the value "Hello"

bool result = String.Equals(s1, s2);

Console.WriteLine("String.Equals(s1, s2) = {0}", result);

// next we will check identity

// ReferenceEquals will return true if both parameters

// point to the same object

// result will be TRUE -both s1 and s2reference

// the same object.

// strings are reference types

// there is no copy made on assignment (s2 = s1)

result = Object.ReferenceEquals(s1, s2);

Console.WriteLine("Object.ReferenceEquals(s1, s2) = {0}", result);

// now we will make a copy of the string

s2 = String.Copy(s1);

// compare string values again

// result will be TRUE - both s1 and s2

// refer tostrings with the value of "Hello"

result = String.Equals(s1, s2);

Console.WriteLine("String.Equals(s1, s2) = {0}", result);

// check identity again

// result will be FALSE

// s1 and s2 point to different object instancesbecause we forced a copy

result = Object.ReferenceEquals(s1, s2);

Console.WriteLine("Object.ReferenceEquals(s1, s2) = {0}", result);

}

}

Reference: http://odetocode.com/Blogs/scott/archive/2005/07/21/1961.aspx