Capitalization Conventions

The guidelines in this chapter lay out a simple method for using case that, when applied consistently, make identifiers for types, members, and parameters easy to read.

To differentiate words in an identifier, capitalize the first letter of each word in the identifier. Do not use underscores to differentiate words, or for that matter, anywhere in identifiers. There are two appropriate ways to capitalize identifiers, depending on the use of the identifier:
  • PascalCasing
  • camelCasing
The PascalCasing convention, used for all identifiers except parameter names, capitalizes the first character of each word (including acronyms over two letters in length), as shown in the following examples:
PropertyDescriptor
HtmlTag
A special case is made for two-letter acronyms in which both letters are capitalized, as shown in the following identifier:
IOStream
The camelCasing convention, used only for parameter names, capitalizes the first character of each word except the first word, as shown in the following examples. As the example also shows, two-letter acronyms that begin a camel-cased identifier are both lowercase.
propertyDescriptor
ioStream
htmlTag
√ DO use PascalCasing for all public member, type, and namespace names consisting of multiple words.
√ DO use camelCasing for parameter names.
The following table describes the capitalization rules for different types of identifiers.
Identifier
Casing
Example
Namespace
Pascal
namespace System.Security { … }
Type
Pascal
public class StreamReader { … }
Interface
Pascal
public interface IEnumerable { … }
Method
Pascal
public class Object {
public virtual string ToString();
}
Property
Pascal
public class String {
public int Length { get; }
}
Event
Pascal
public class Process {
public event EventHandler Exited;
}
Field
Pascal
public class MessageQueue {
public static readonly TimeSpan
InfiniteTimeout;
}
public struct UInt32 {
public const Min = 0;
}
Enum value
Pascal
public enum FileMode {
Append,

}
Parameter
Camel
public class Convert {
public static int ToInt32(string value);
}

Most compound terms are treated as single words for purposes of capitalization.
X DO NOT capitalize each word in so-called closed-form compound words.
These are compound words written as a single word, such as endpoint. For the purpose of casing guidelines, treat a closed-form compound word as a single word. Use a current dictionary to determine if a compound word is written in closed form.
Pascal
Camel
Not
BitFlag
bitFlag
Bitflag
Callback
callback
CallBack
Canceled
canceled
Cancelled
DoNot
doNot
Don’t
Email
email
EMail
Endpoint
endpoint
EndPoint
FileName
fileName
Filename
Gridline
gridline
GridLine
Hashtable
hashtable
HashTable
Id
id
ID
Indexes
indexes
Indices
LogOff
logOff
LogOut
LogOn
logOn
LogIn
Metadata
metadata
MetaData, metaData
Multipanel
multipanel
MultiPanel
Multiview
multiview
MultiView
Namespace
namespace
NameSpace
Ok
ok
OK
Pi
pi
PI
Placeholder
placeholder
PlaceHolder
SignIn
signIn
SignOn
SignOut
signOut
SignOff
UserName
userName
Username
WhiteSpace
whiteSpace
Whitespace
Writable
writable
Writeable

Languages that can run on the CLR are not required to support case-sensitivity, although some do. Even if your language supports it, other languages that might access your framework do not. Any APIs that are externally accessible, therefore, cannot rely on case alone to distinguish between two names in the same context.
X DO NOT assume that all programming languages are case sensitive. They are not. Names cannot differ by case alone.
Portions © 2005, 2009 Microsoft Corporation. All rights reserved.
Reprinted by permission of Pearson Education, Inc. from Framework Design Guidelines: Conventions, Idioms, and Patterns for Reusable .NET Libraries, 2nd Edition by Krzysztof Cwalina and Brad Abrams, published Oct 22, 2008 by Addison-Wesley Professional as part of the Microsoft Windows Development Series.

Most useful Visual Studio 2013 keyboard shortcuts

1. Manage Visual Studio
Ctrl+S Save current file
Ctrl+Shift+S Save all files
Ctrl+Shift+N Create new project
Ctrl+O Open file
Ctrl+Shift+O Open project
Ctrl+Shift+A Add item to project
Esc Close menu or dialog
Ctrl+P Print
Shift+Alt+Enter Toggle full screen mode
Ctrl+F4 Close current tab
Ctrl+F6/Ctrl+Shift+F6 Go to next / go to previous window
Ctrl+Tab, then Arrow keys Press and hold Ctrl+Tab, then using arrow keys gives a small task manager with all open files and views
▲ up

minus

2. Bookmarks
Ctrl+K+K Toogle bookmark
Ctrl+K+N Goto next bookmark
Ctrl+K+P Goto previous bookmark
Ctrl+K+L Clear all bookmarks
Ctrl+\+T Show Task List (including code shortcuts)
*if somebody figures out additional shortut keys on how to use code shortcuts, please edit this page and add.
▲ up

minus

Find, Replace, and Goto
Ctrl+F Find and replace dialog box
F3/Shift+F3 Find next / find previous
Ctrl+H Display Replace options on the quick tab
Shift+F12 Find all references for selected symbol
Ctrl+Shift+F Find in files
Alt+F3s Stop current find in files operation
Ctrl+F3/Ctrl+Shift+F3 Find next / find previous in selected text
Alt+F12 Find symbol
Ctrl+D Put cursor in find/command box of the toolbar. Use ctrl+/ in Visual C#
Ctrl+I/Ctrl+Shift+I Incremental search / reverse incremental search
Shift+Alt+F12 Quick find symbol
Ctrl+, Display Navigate-To dialog box
Ctrl+G Goto line number
Ctrl+] Go to matching brace in source file
Shift+Ctrl+Arrow down Jump to next occurrence of highlighted symbol
Shift+Ctrl+Arrow up Jump to previous occurrence of highlighted symbol
minus

Undo, Redo, Copy, Paste
Ctrl+x, Ctrl+c, Ctrl+V Cut, copy, paste
Ctrl+Shift+V Pastes an item from the Clipboard ring
Ctrl+Z Undo
Ctrl+Y Redo (or Shift+Alt+Backspace, or Ctrl+Shift+Z)
minus

Select Text
Shift+Arrow Keys Extend selection one character/one line
Ctrl+Shift+End/Ctrl+Shift+Home Extend selection to end / to beginning of document
Ctrl+Shift+] Extend selection to nexst brace
Shift+End/Shift+Home Extend selection to end / to beginning of line
Shift+Page Down/Shift+Page Up Extends selection down one page / up one page
Ctrl+W Select current word
Esc Cancel Selection
Ctrl+Shift+Page Down/Page Up Moves cursor and extend selection to the last line / first line in view.
Ctrl+Shift+Arrow Right/Arrow Left Extend selection one word to the right / one word to the left
Ctrl+A Select All

minus

Collapse Items
Ctrl+M+M Collapse / un-collapse current preset area (e.g. method)
Ctrl+M+H Collpase/hide current selection
Ctrl+M+O Collapse declaration bodies
Ctrl+M+A Collapse all
Ctrl+M+X Uncollapse all
Ctrl+mctrl+T Collapse HTML tag
minus

Edit Code
Ctrl+L Cut current line
Ctrl+Shift+L Delete current line or selection of lines
Ctrl+Delete Delete word to right of cursor
Ctrl+Backspace Delete word to left of cursor
Ctrl+Enter Enter blank line above cursor
Ctrl+Shift+Enter Enter blank line below cursor
Ctrl+Shift+U Make uppercase
Ctrl+U Make lowercase (reverse uppercase)
Ctrl+K+C Comment selected text
Ctrl+K+U Uncomment selected text
Ctrl+K+\ Remove white space and tabs in selection or around current cursor position
Ctrl+K+D Format document to code formatting settings
Ctrl+K+F Format selection to code formatting settings
Ctrl+Shift+Space Display parameter required for selected method
Ctrl+Shift+8 Visualize whitespace (or press Ctrl+r, then Ctrl+w)
Ctrl+K+D Format document to code formatting settings
Ctrl+K+F Format selection to code formatting settings
Ctrl+Shift+T Transpose word to right of cursor; makes b=a out of a=b if cursor was in front of a
Ctrl+T Transpose character left and right of cursor; cursor between ab would make ba
Shift+Alt+T Transpose line: Move line below cursor up and current line down.
minus

IntelliSense and Code Helper
Ctrl+Space Autocomplete word from completion list (or alt+right arrow)
Ctrl+Shift+Space Show parameter info
Ctrl+F12 Display symbol definition
F12 Display symbol declaration
Ctrl+J Open IntelliSense completion list
▲ up

minus

5. Build and Debug
F6 Build solution (or Ctrl+shift+b)
Ctrl+Alt+F7 Rebuild solution
Ctrl+Break Cancel build process
Ctrl+\+E Show error list
F9 Toggle breakpoint
Ctrl+B Insert new function breakpoint
F5 Start debugging
F11 Debug / step into
F10 Debug / step over
Shift+F11 Debug / step out
Ctrl+F10 Debug / run to cursor
Ctrl+Alt+Q Show Quickwatch window
Ctrl+Shift+F10 Set current statement to be the next executed
Alt+* (on numeric keyboard) Show nexst statement
Ctrl+Alt+E Show Exception dialog box
Ctrl+F11 Toggle between disassembly and user code view
Shift+F5 Stop Debugging
Ctrl+F5 Bypass debugger
Ctrl+Alt+P Show attach to process window
Ctrl+Alt+break Break all executing threads
▲ up

minus

6. Tool Windows
Ctrl+/ Put cursor in the find/command box in toolbar
Ctrl+K+B Open code snippet manager window
Alt+F11 Open macro IDE window
Ctrl+K+W Open bookmark window
Ctrl+Alt+K Open call hierarchy window
Ctrl+Shift+C Open class view window
Ctrl+Alt+A Open Command window
Ctrl+Shift+O Open Output window
Ctrl+Shift+E Open Resource view window
Ctrl+Alt+S Open Server explorer window
Ctrl+Shift+L Open Solution explorer window
Shift+Esc Close Find & Replace Window

Surround With
Ctrl+K, Ctrl+S
Ctrl+K, S
Error List
Ctrl+\, E
Full Screen
Shift+Alt+Enter
Navigate Backward
Ctrl+-
Navigate Forward
Ctrl+Shift+-
Next Error
Ctrl+Shift+F12
Zoom In
Ctrl+Shift+.
Zoom Out
Ctrl+Shift+,

Group time by hour from datetime field in SQL Server

  SELECT CAST(ENTRY_DATE as date) AS ForDate,
       DATEPART(hour,ENTRY_DATE) AS OnHour,
       COUNT(*) AS Totals
FROM [BATB].[dbo].[CONSUMER_INFO]
GROUP BY CAST(ENTRY_DATE as date),
       DATEPART(hour,ENTRY_DATE)
       Having CAST(ENTRY_DATE as date)=’2014-02-12′
       Order by DATEPART(hour,ENTRY_DATE) ASC

Date validation in JQuery

 

function CheckDate(dateValue) {
var validDatePattern = /^(?:(?:31(\/|-|\.)(?:0?[13578]|1[02]))\1|(?:(?:29|30)(\/|-|\.)(?:0?[1,3-9]|1[0-2])\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})$|^(?:29(\/|-|\.)0?2\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00))))$|^(?:0?[1-9]|1\d|2[0-8])(\/|-|\.)(?:(?:0?[1-9])|(?:1[0-2]))\4(?:(?:1[6-9]|[2-9]\d)?\d{2})$/;

if (validDatePattern.test(dateValue)) {
return true;
}
else {
return false;
}
}

JQuery DatePicker Year Range

    $(function () {
        $(“.datePicker”).datepicker({
            changeMonth: true,
            changeYear: true,
            dateFormat: ‘dd-mm-yy’,
            yearRange: “c-1:c” // c=current year
        });
    });

Calling SignalR Hub Method from MVC Action Method

using Microsoft.AspNet.SignalR;
using Microsoft.AspNet.SignalR.Hubs;

Public ActionResult MyControllerMethod()
{
var context = GlobalHost.ConnectionManager.GetHubContext<MyHub>();
context
.Clients.All.methodInJavascript("hello world");
// or
context
.Clients.Group("groupname").methodInJavascript("hello world");
}