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
using System; | |
using System.Runtime.InteropServices; | |
public static class Program { | |
public static unsafe void Main (string[] args) { | |
var bytes = new byte[8]; | |
fixed (byte* pBytes = bytes) { | |
var pStruct = (MyStruct*)pBytes; | |
*pStruct = new MyStruct { |
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
using System; | |
using JSIL; | |
using JSIL.Meta; | |
public static class Program { | |
public static int x = 10; | |
public static int y = 20; | |
public static void Main () { | |
dynamic document = Builtins.Global["document"]; |
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
using System; | |
using System.Reflection; | |
using System.Collections.Generic; | |
public static class Program { | |
public static void Main (string[] args) { | |
Common.Util.ListMembers<MethodInfo>( | |
typeof(T), | |
BindingFlags.DeclaredOnly | BindingFlags.Static | BindingFlags.Public | |
); |
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
using System; | |
public static class Program { | |
public static void Main (string[] args) { | |
Action<int> a = | |
(i) => Console.WriteLine("a({0})", i); | |
Action<int> b = | |
(i) => Console.WriteLine("b({0})", i); | |
Action<int> c = (Action<int>)Delegate.Combine(a, b); |
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
using System; | |
public class Foo { | |
public void Func1 () { | |
Console.Write("F1 "); | |
} | |
public virtual void Func2 () { | |
Console.Write("F2 "); | |
this.Func1(); |
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
using System; | |
public static class Program { | |
public static void Increment (ref int x) { | |
x += 1; | |
} | |
public static void IncrementTwice (ref int x) { | |
Increment(ref x); | |
Increment(ref x); |
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
using System; | |
public class GenericClass<T> { | |
public virtual void Method (T value) { | |
Console.WriteLine("GenericClass<{0}>.Method({1})", typeof(T), value); | |
} | |
} | |
public class MyClass<T> : GenericClass<T> { | |
public override void Method (T value) { |
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
// http://msdn.microsoft.com/en-us/library/aa645739%28v=vs.71%29.aspx | |
// events1.cs | |
using System; | |
namespace MyCollections | |
{ | |
using System.Collections; | |
// A delegate type for hooking up change notifications. | |
public delegate void ChangedEventHandler(object sender, EventArgs e); |
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
using System; | |
public static class Program { | |
public static unsafe void Main (string[] args) { | |
var ints = new int[] { 0, 1, 2, 3 }; | |
fixed (int* pInts = ints) { | |
var pBytes = (byte*)pInts; | |
for (var i = 0; i < (ints.Length * 4); i++) |
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
using System; | |
public class Program { | |
public static void Main () { | |
var i = 0; | |
var x = 1L; | |
Console.WriteLine("Left shift"); | |
Console.WriteLine(x); | |
Console.WriteLine("{0} {1}", 1, Format(x << 1)); | |
NewerOlder