Skip to content

Instantly share code, notes, and snippets.

@begedin
begedin / LINQ2.cs
Created May 15, 2013 11:26
This is also LINQ
var _Persons = _PersonList.Where(x => x.Name == "Bob");
@begedin
begedin / LINQ1.cs
Created May 15, 2013 11:24
This is LINQ
var _Persons = from person in _PersonList
where person.Name == "Bob"
select person;
@begedin
begedin / main.cs
Created May 7, 2013 14:32
Run single instance process from console.
[STAThread()]
static void Main(string[] args)
{
Console.Title = "Call App";
// hide the console window
setConsoleWindowVisibility(false, Console.Title);
// look for all running instances of the app
var runningProcessByName = Process.GetProcessesByName("notepad");
if (runningProcessByName.Length == 0)
@begedin
begedin / setforegroundwindwo.cs
Created May 7, 2013 14:30
Import SetForegroundWindow
[DllImport("User32.dll")]
private static extern bool SetForegroundWindow(IntPtr hWnd);
@begedin
begedin / runsingle.cs
Created May 7, 2013 14:29
Run notepad if it isn't running.
var runningProcessByName = Process.GetProcessesByName("notepad");
if (runningProcessByName.Length == 0)
{
Process.Start("notepad.exe");
}
Console.Title = "Call App";
// hide the console window
setConsoleWindowVisibility(false, Console.Title);
@begedin
begedin / setConsoleWindowVisibility.cs
Created May 7, 2013 14:27
Function to set console window visibility.
public static void setConsoleWindowVisibility(bool visible, string title)
{
IntPtr hWnd = FindWindow(null, title);
if (hWnd != IntPtr.Zero)
{
if (!visible)
//Hide the window
ShowWindow(hWnd, 0); // 0 = SW_HIDE
else
//Show window again
@begedin
begedin / callnotepad.cs
Created May 7, 2013 14:23
Calling Notepad.exe
Process.Start("notepad.exe")
@begedin
begedin / GridView.html
Last active December 17, 2015 01:59
Typical ASP.NET GridVIew Control Creation
<asp:GridView
ID="gvMyGridID" runat="server"
DataSourceID="myDataSource"
AutoGenerateColumns="False"
GridLines="None"
AllowPaging="true"
CssClass="myGridClass"
PagerStyle-CssClass="myPagerClass"
AlternatingRowStyle-CssClass="myAltRowClass">
@begedin
begedin / Using Interop and Diagnostic.cs
Created May 7, 2013 14:22
Including InteropServices and Diagnostics
using System.Runtime.InteropServices;
using System.Diagnostics;