This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static class ProcessDetector | |
{ | |
public static bool IsWin64(Process process) | |
{ | |
if (Environment.Is64BitOperatingSystem) | |
{ | |
IntPtr processHandle; | |
bool retVal; | |
try |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static bool IsFatal(this Exception exception) | |
{ | |
while (exception != null) | |
{ | |
if (exception as OutOfMemoryException != null && exception as InsufficientMemoryException == null || exception as ThreadAbortException != null || | |
exception as AccessViolationException != null || exception as SEHException != null || exception as StackOverflowException != null) | |
{ | |
return true; | |
} | |
else |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <assert.h> | |
using namespace std; | |
class B; | |
class A | |
{ | |
public: | |
A(); | |
~A(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class NoDerive { | |
NoDerive(){}; | |
public: | |
static NoDerive GetNoDerive(){ return NoDerive();}; | |
~NoDerive(){}; | |
}; | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Program | |
{ | |
public static int StaticInt = 0; | |
static Func<string> delegate1 = new Func<string>(StaticInt.ToString); | |
static Func<string> delegate2 = new Func<string>(() => StaticInt.ToString()); | |
static void Main(string[] args) | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class MyClass | |
{ | |
public MyClass() | |
{ | |
Console.WriteLine("MyClass is created!"); | |
} | |
} | |
public class Program |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Program | |
{ | |
static int threadID=0; | |
[System.Runtime.InteropServices.DllImport("kernel32.dll")] | |
static extern IntPtr OpenThread(uint dwDesiredAccess, bool bInheritHandle, uint dwThreadId); | |
[System.Runtime.InteropServices.DllImport("kernel32.dll")] | |
static extern bool TerminateThread(IntPtr hThread, uint dwExitCode); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
foreach (var s in DriveInfo.GetDrives()) | |
{ | |
if (s.IsReady) | |
{ | |
Console.WriteLine(s.Name); | |
Console.WriteLine(s.TotalSize); | |
Console.WriteLine(s.AvailableFreeSpace); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// add the following reference | |
//Microsoft.SqlServer.ConnectionInfo | |
//Microsoft.SqlServer.Management.Sdk.Sfc | |
//Microsoft.SqlServer.Smo | |
//Microsoft.SqlServer.SmoExtended | |
//Microsoft.SqlServer.SqlEnum | |
public void BackupDatabase(string databaseName, string userName, string password, string serverName, | |
string destinationPath) | |
{ | |
//Define a Backup object variable. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace __hidden__ { | |
struct print { | |
bool space; | |
print() : space(false) {} | |
~print() { std::cout << std::endl; } | |
template <typename T> | |
print &operator , (const T &t) { | |
if (space) std::cout << ' '; | |
else space = true; |