C# Tricks


Warning: WP_Syntax::substituteToken(): Argument #1 ($match) must be passed by reference, value given in D:\InetPub\vhosts\kwu-1639.package\kennywu.info\wwwroot\wp-content\plugins\wp-syntax\wp-syntax.php on line 380

#region
… your code here inside a collapsible region.
#endregion

Save code in the toolbox, and use them later on.
Drag the selected lines of code into the General tab of the toolbox and drop them.

Ternary operator : ?

bool informal = true;
string name =informal : "Chuck" ? "Charles";  // Returns "Chuck"

Pattern search using SQL


Warning: WP_Syntax::substituteToken(): Argument #1 ($match) must be passed by reference, value given in D:\InetPub\vhosts\kwu-1639.package\kennywu.info\wwwroot\wp-content\plugins\wp-syntax\wp-syntax.php on line 380

Instead of exact matching, the following code allows you to do a pattern search by joining two table using like operator.

SELECT *
FROM Table1
INNER JOIN Table2 ON Table1.col LIKE '%' + Table2.col + '%'