Foreach C#

A program iterates over a collection. The index of each element is not needed. Only the elements are needed. With foreach we access just the elements. A foreach-loop, this is the easiest, least error-prone loop. It is preferred in many program contexts. Here are some samples: using System; class Program { static void Main() { string[] pets = { “dog”, “cat”, “bird” }; // … Loop with the foreach keyword. foreach (string value in pets) { Console.WriteLine(value); } }…

Read More

Find the Server Name or Instance Name using T-SQL

The following instructions are supposed to return the same results,  but sometimes the results can be different. The reason is that SERVERPROPERTY automatically reports changes in the network name of the computer, while @@SERVERNAME don’t. SELECT CONVERT(sysname, SERVERPROPERTY(N’servername’)) GO SELECT @@SERVERNAME When they are run on the default instance they return just the server name, but when run over a named instance they return the server name in the following format: servername/instancename.

Read More

Visual Studio 2015 keyboard shortcuts – The complete list

Analyze Navigate Backward Shift+Alt+3 Navigate Forward Shift+Alt+4 Architecture New Code Map Ctrl+\, Ctrl+O New UMLor Layer Diagram Ctrl+\, Ctrl+N Architecture Context Menus Add Node Ins Both Dependencies B Incoming Dependencies I Outgoing Dependencies O New Comment Ctrl+Shift+K Ctrl+E, C Remove Del Rename F2 Build Build Solution Ctrl+Shift+B Cancel Ctrl+Break Compile Ctrl+F7 Run Code Analysison Solution Alt+F11 Class Diagram Collapse Num – Expand Num + Class View Context Menus Properties Alt+Enter Misc Commit All Edits Shift+Alt+U Move Left Edgetotheleft Ctrl+Shift+,…

Read More

Enable or Disable Multiple RDP Sessions in Windows 2012

How to Enable/Disable Multiple RDP Sessions in Windows 2012. By default, Windows 2012 servers allow a single Remote Desktop session. If only one session is available and you take over another person’s live session, you may choose to enable multiple RDP sessions. This article describes the process for enabling and disabling multiple sessions. Enable Multiple RDP Sessions  Log into the server using Remote Desktop. Open the start screen (press the Windows key) and type gpedit.msc and open it Go…

Read More