To split a string by multiple characters into an array, you can try the following:

using System;
using System.Text.RegularExpressions;

class myClass
{
    static void Main()
    {
	string myValue = "line1\r\nline2\r\nline3";

	string[] myLines = Regex.Split(myValue , "\r\n");

	foreach (string myLine in myLines )
	{
	    Console.WriteLine(myLine);
	}
    }
}

To add border thickness to an object from code behind, you can try the following:

Border1.BorderThickness = new System.Windows.Thickness(2, 2, 2, 2);

If you want to launch a web browser from code, you can do the following:

using Microsoft.Phone.Tasks;

WebBrowserTask webbrowser = new WebBrowserTask();
webbrowser.URL = "www.zapi.co.nz";
webbrowser.Show();

If you want a quick way to create DataContext for your Windows Phone applications, you can include this addon for Visual Studio which will save you a lot of time:
http://sqlcetoolbox.codeplex.com/

If you want to scroll to the top of a page that is using a control ScrollViewer, you can do this in code behind as follows:

ScrollViewer.ScrollToVerticalOffset(0);

Split String Into Array by Delimiter

Posted: December 14, 2011 in ASP.Net

To split a string by a delimiter into an array, you can try the following:

string myContact = "1|2|3|4|5";
string[] myContactArray = myContact.Split('|');
foreach (string myContactValue in myContactArray)
{
  Console.WriteLine(myContactValue);
}    

Iterate Through List Collection

Posted: December 14, 2011 in ASP.Net

To iterate through a List collection, you can try the following:

List<int> myList = new List<int>();
myList .Add(1);
myList .Add(2);
myList .Add(3);

// Loop through List with foreach statement
foreach (int myInt in MyList) 
{
  Console.WriteLine(myInt);
}

// Loop through List with for statement
for (int i = 0; i < MyList.Count; i++) 
{
  Console.WriteLine(MyList[i]);
}

Insert Double Quotes (“) Into String

Posted: December 13, 2011 in ASP.Net

To insert double quotes (“) into a string, you can try the following:

string myString = "\"someString\"";

To find the nth maximum record, you can try the following:

SELECT o.name,
       user_name(dp.grantee_principal_id) grantee,
       user_name(dp.grantor_principal_id) grantor ,
       dp.permission_name ,
       dp.state_desc,
       o.type_desc
FROM   sys.database_permissions dp 
       INNER JOIN sys.objects   o  ON o.object_id = dp.major_id
                                  AND dp.class     = 1 
                                  AND o.type IN ('U', 'P', 'V', 'Fn') -- U(User Tables), P(Store Procedure), V(View), Fn(Function)
WHERE    dp.type IN ('SL', 'IN', 'UP', 'EX') -- SL(Select), IN(Insert), Up(Update), Ex(Execute)
ORDER BY o.type_desc, 
         o.name;

To find the nth maximum record, you can try the following:

-- Declare variables
DECLARE @lv_string VARCHAR(500);

-- Initialise variable
SET @lv_string = 'Do something      with      the    result  !';

-- Loop until all double spaces are replaced with single space
WHILE CHARINDEX(SPACE(2), @lv_string) > 0 
BEGIN
   SET @lv_string = REPLACE(@lv_string, SPACE(2), SPACE(1));
END;

-- Return string
SELECT @lv_string;