This was some thing i got to learn yesterday. I was using some profiler and some random ways to get the time. but this was a quick one. I knew something like this existed but never bothered until I had to use it
Thursday, September 30, 2010
Find the time elapsed between two statements C#
Posted by vaibhav at 7:02 AM 0 comments
Thursday, March 25, 2010
Visual studio 2008 shortcuts
Visual studio 2008 shortcuts
ALT + CTRL + "e": open the Exceptions window
CTRL + "k" + "f" and CRTL + "k" + "d": these two will format the code in the window to be nicely indented. Using "d" will format all the document while using "f" will format only selected text. The formatting is for all types of documents, HTML, Xaml, XML, C#… This one is my favorite.
SHIFT + Del: cut the entire row from the document and past it to the clipboard.
CTRL + "k" + "c" and CTRL + "k" + "u": These two are for commenting selected text (the "c" options) and uncommenting selected text (the "u" option).
ALT + ENTER: this little shortcut will open up the Properties window
CTRL + "k" + "s": opens up the code snippets dialogue within the code
F12: I think you all know this but still F12 is the shortcut for the "Go to definition" command which will take you to the definition of the object your marker is currently on.
F9: add a breakpoint to the code line your marker is currently at. Clicking F9 again will remove this breakpoint from that line.
CTRL + ALT + "q": This one will open the Quick watch window
Ctrl+K, Ctrl+F - Format selected block of code
Ctrl+Shift+B -Build solution
References
http://www.dev102.com/2008/04/17/10-visual-studio-shortcuts-you-must-know/
http://www.85turns.com/2008/07/03/favorite-visual-studio-2008-keyboard-shortcuts-2/
Posted by vaibhav at 7:28 AM 0 comments
Friday, March 5, 2010
Get an alert from TFS when a work item is assigned to you(me)
Thanks to :Jan Tanis (http://blog.jantanis.net/2009/09/work-item-email-notification-with-team.html)
How to setup email notification on having assigned a Work Item to you?
1. Download and install Team Foundation Power Tool for Visual Studio @ http://www.microsoft.com/downloads/details.aspx?FamilyId=FBD14EEA-781F-45A1-8C46-9F6BA2F68BF0&displaylang=en#filelist
2. Start Visual Studio and open the Alert Editor
3. Add new Alert -> Work Item alert -> A Work Item was assigned to me
4. Change your name in “Send To” to your current email address
5. Collapse Work Items Alerts to ensure saving (workaround to start saving procedure)
6. DONE!
Posted by vaibhav at 7:39 AM 0 comments
Friday, February 12, 2010
Executing C# WinForms application in Partial trust mode
Its pretty easy to do in VS 2010
->Open solution explorer for a solution
->Right click the project you wish to run in partial trust mode
->select properties
->select the security tab
->check "Enable ClickOnce security"
-> select "This is a partial trust application"
and your application will run in partial trust mode from now on...
Vaibhav
Posted by vaibhav at 5:55 AM 0 comments
Tuesday, February 9, 2010
String matching with pattern having wildcard characters in C#
The solution makes use of Regex class in .NET and supports both '*' and '?' wild cards.
private bool IsWildcardMatch(String wildcard, String text, bool casesensitive)
{
System.Text.StringBuilder sb = new System.Text.StringBuilder(wildcard.Length + 10);
sb.Append("^");
for (int i = 0; i < wildcard.Length; i++)
{
char c = wildcard[i];
switch(c)
{
case '*':
sb.Append(".*");
break;
case '?':
sb.Append(".");
break;
default:
sb.Append(System.Text.RegularExpressions.Regex.Escape(wildcard[i].ToString()));
break;
}
}
sb.Append("$");
System.Text.RegularExpressions.Regex regex;
if (casesensitive)
regex = new System.Text.RegularExpressions.Regex(sb.ToString(), System.Text.RegularExpressions.RegexOptions.None);
else
regex = new System.Text.RegularExpressions.Regex(sb.ToString(), System.Text.RegularExpressions.RegexOptions.IgnoreCase);
return regex.IsMatch(text);
}
I picked up the above sample from http://adamsen.wordpress.com/2008/10/16/c-string-wildcard-match/ but it only supported '*" and not '?'.
I added a case block to support ? as well.
vaibhav
Posted by vaibhav at 9:00 AM 0 comments