Skip to content

Instantly share code, notes, and snippets.

View VladimirReshetnikov's full-sized avatar

Vladimir Reshetnikov VladimirReshetnikov

View GitHub Profile
using System;
using System.Runtime.InteropServices;
class Program
{
static void Main()
{
dynamic calc = Activator.CreateInstance(Marshal.GetTypeFromCLSID(new Guid(148736, 0, 0, 192, 0, 0, 0, 0, 0, 0, 70)));
Console.WriteLine(calc.Evaluate("2+3*5"));
}
private static bool IsSimpleBinaryOperator(SyntaxKind kind)
{
switch (kind)
{
case SyntaxKind.AddExpression:
case SyntaxKind.MultiplyExpression:
case SyntaxKind.SubtractExpression:
// ... more cases skipped ...
case SyntaxKind.RightShiftExpression:
return true;
static void Foo<T>(T x)
{
if (x == null) // Possible compare of value type with 'null'
{
}
}
using System;
using System.Linq;
class Program
{
static void Main()
{
if (true.Any is object) { }
if (ICloneable.Clone is object) { }
}
class A<T>
{
static void Foo(T[] a) { }
class B : A<T> { }
class C<T>
{
static void Foo()
{
class A
{
static void Main()
{
var x = Foo<int> is Foo<int> is Foo<int>; // Will this parse successfully?
}
void Foo<T>() { }
}
struct S
{
int x;
S(int y)
{
if (GetType is object) { }
if (Equals is object) { }
this.x = y;
using System;
static class Program
{
static void Main()
{
for (var ch = char.MinValue; ch <= char.MaxValue; ch++)
{
Console.WriteLine(ch);
}
using System;
using System.Collections.Generic;
struct S
{
ValueType x;
static void Main()
{
var s = new S();
class A<T>
{
class B : A<int>
{
}
class C : B
{
C GetThis()
{