COALESCE function instead of long CASE WHEN … ELSE (T-SQL)
0Instead of using long “SELECT … CASE WHEN … ELSE …” construction, you can use the COALESCE function when you need to find a value that is not NULL. Lets review the following T-SQL expression, in which we need to select an available “source”:
http://dotnettipoftheday.org/tips/sql-coalesce.aspx
SELECT TheSource =
CASE
WHEN localSource IS NOT NULL THEN localSource
WHEN intranetSource IS NOT NULL THEN intranetSource
WHEN internetSource IS NOT NULL THEN internetSource
ELSE ''
END
FROM ...
Now lets rewrite the code More >
Correct event invocation
0http://dotnettipoftheday.org/tips/correct-event-invocation.aspx
Be aware that if there are no subscribers a .NET event will be null. Therefore when raising the event from C# test it for null first.
public event EventHandler SelectedNodeChanged;
protected virtual void OnSelectedNodeChanged(object sender, EventArgs e)
{
//Event will be null if there are no subscribers
if (SelectedNodeChanged != null)
{
SelectedNodeChanged(this, e);
}
}
However in multithreaded application the last subscriber can unsubscribe immediately after the null check and before the event is raised. To avoid a null reference exception make a More >
Keyboard shortcuts for Word
0Command Name Shortcut Keys ------------------------------------------------------------------------ All Caps CTRL+SHIFT+A Annotation ALT+CTRL+M App Maximize ALT+F10 App Restore ALT+F5 Apply Heading1 ALT+CTRL+1 Apply Heading2 ALT+CTRL+2 Apply Heading3 ALT+CTRL+3 Apply List Bullet CTRL+SHIFT+L Auto Format ALT+CTRL+K Auto Text F3 or ALT+CTRL+V Bold CTRL+B or CTRL+SHIFT+B Bookmark CTRL+SHIFT+F5 Browse Next CTRL+PAGE DOWN Browse Previous CTRL+PAGE UP Browse Sel ALT+CTRL+HOME Cancel ESC Center Para CTRL+E Change Case SHIFT+F3 Char Left LEFT Char Left Extend SHIFT+LEFT Char Right RIGHT Char Right Extend SHIFT+RIGHT Clear DELETE Close or Exit ALT+F4 Close Pane ALT+SHIFT+C Column Break
SQL Server Date Formats
0
Keyboard Shortcuts
0Find keyboard shortcuts for the following Microsoft products:
Windows, Internet Explorer, Office 2010, Office 2007, Office 2003, More Office Keyboard Shortcuts, and Windows Media
http://www.microsoft.com/enable/products/keyboard.aspx
Visual Studio .NET 2003 Keyboard Shortcuts
0Visual Studio .NET 2003 Keyboard Shortcuts
Global
Alt+-
View
ObjectBrowserBack
Ctrl+-
View
NavigateBackward
Ctrl+Shift+-
View
NavigateForward
Shift+Alt+-
View
ObjectBrowserForward
Ctrl+/
Tools
GoToCommandLine
Ctrl+Shift+1
View
BrowseNext
Ctrl+Shift+2
View
BrowsePrevious
Ctrl+Shift+8
View
PopBrowseContext
Ctrl+A
Edit
SelectAll
Ctrl+Alt+A
View
CommandWindow
Ctrl+Shift+A
File
AddNewItem
Shift+Alt+A
File
AddExistingItem
Ctrl+Alt+B
Debug
Breakpoints
Ctrl+B
Debug
NewBreakpoint
Ctrl+Shift+B
Build
BuildSolution
Alt+Bkspce
Edit
Undo
Ctrl+Alt+Break
Debug
BreakAll
Ctrl+Break
Build
Cancel
Ctrl+Alt+C
Debug
CallStack
Ctrl+Shift+C
View
ClassView
Ctrl+Alt+D
Debug
Disassembly
Ctrl+D
Edit
GoToFindCombo
Del
Edit
Delete
Shift+Del
Edit
Cut
Down Arrow
Edit
MoveControlDownGrid
Shift+Down Arrow
Edit
SizeControlDownGrid
Visual Studio .NET 2005 Keyboard Shortcuts
0Visual Studio .NET 2005 Keyboard Shortcuts
Class Diagram
Num +
ClassDiagram
Expand
Shift+Alt+B
Edit
ExpandCollapseBaseTypeList
Ctrl+Del
Edit
Delete
Del
Edit
RemovefromDiagram
Enter
View
ViewCode
Shift+Alt+L
Edit
NavigateToLollipop
Num -
ClassDiagram
Collapse
DataSet Editor
Ins
Data
InsertColumn
Ctrl+L
Data
Column
Deployment Designer
Shift+Alt+D
Diagram
RedrawConnection
Shift+Alt+T
Diagram
RerouteConnection
Global
Ctrl+-
View
NavigateBackward
Ctrl+Shift+-
View
NavigateForward
Ctrl+.
View
ShowSmartTag
Ctrl+/
Tools
GoToCommandLine
Ctrl+\, D
View
CodeDefinitionWindow
Ctrl+\, E
View
ErrorList
Ctrl+\, T
View
TaskList
Ctrl+Shift+1
View
BrowseNext
Ctrl+Shift+2
View
BrowsePrevious
Ctrl+Shift+7
View
ForwardBrowseContext
Ctrl+Shift+8
View
PopBrowseContext
Visual Studio .NET 2008 Keyboard Shortcuts
0Visual Studio .NET 2008 Keyboard Shortcuts
Class Diagram
Num +
ClassDiagram
Expand
Shift+Alt+B
Edit
ExpandCollapseBaseTypeList
Del
Edit
RemovefromDiagram
Shift+Alt+L
Edit
NavigateToLollipop
Num -
ClassDiagram
Collapse
DataSet Editor
Ins
Data
InsertColumn
Ctrl+L
Data
Column
Global
Ctrl+-
View
NavigateBackward
Ctrl+Shift+-
View
NavigateForward
Ctrl+.
View
ShowSmartTag
Ctrl+/
Edit
GoToFindCombo
Ctrl+Shift+1
View
BrowseNext
Ctrl+Shift+2
View
BrowsePrevious
Ctrl+5
Debug
LocationToolbar
Ctrl+6
Debug
LocationToolbar
Ctrl+7
Debug
LocationToolbar
Ctrl+Shift+7
View
ForwardBrowseContext
Ctrl+8
Debug
LocationToolbar
Ctrl+Shift+8
View
PopBrowseContext
Ctrl+9
Debug
LocationToolbar
Ctrl+A
Edit
SelectAll
Ctrl+Shift+A
Project
AddNewItem
Shift+Alt+A
Project
AddExistingItem
Ctrl+Alt+B
Debug
Breakpoints
.NET Compact Framework DateTime with Milliseconds
1
using System;
using System.Windows.Forms;
namespace DateTimeWithMilliSeconds
{
public partial class Main : Form
{
private DateTime _startDateTime;
private int _startTick;
public Main()
{
InitializeComponent();
}
private void Main_Load(object sender, EventArgs e)
{
// Inialize with current DateTime and TickCount.
_startDateTime = DateTime.Now;
// TickCount returns the number milliseconds ellapsed since the system started.
_startTick = Environment.TickCount;
}
private void btnGetDateTime_Click(object sender, EventArgs e)
{
lblDateTime.Text = GetDateTimeWithMilliSeconds().ToString("yyy.MM.dd HH:ss.fff");
}
/// <summary>
/// Get DateTime with milliseconds
/// </summary>
/// <returns>DateTime</returns>
public DateTime GetDateTimeWithMilliSeconds()
{
return _startDateTime.AddMilliseconds(Environment.TickCount - _startTick);
}
}
}