Monday 16 May 2016

Run a C# .cs file from a Powershell Script

$source =
@"
   public class BasicTest
   {
     public static int Add(int a, int b) {
        return (a + b);
     }

     public int Multiply(int a, int b) {
       return (a * b);
     }
   }
"@

# type definition - must be declared
Add-Type -TypeDefinition $source
 

# access a static method
[BasicTest]::Add(4, 3)

# create instance of class and call a non-static method
$basicTestObject = New-Object BasicTest
$basicTestObject.Multiply(5, 2)



Wednesday 4 May 2016

Escape text for HTML - Embed Symbols in HTML

ASP.NET 
    var encoded = System.Web.HttpUtility.HtmlEncode(un_encoded);

C# console and Windows apps 
    var encoded = System.Security.SecurityElement.Escape(un_encoded);


Upgrade Windows 11 Home to Windows 11 Pro

Disable internet connection (Wi-Fi, Internet, etc.) Change the product key using the following Generic product key:                     VK7J...