All pastes #1215603 Raw Edit

Someone

public text v1 · immutable
#1215603 ·published 2008-10-01 08:53 UTC
rendered paste body
using System;

namespace Martin.Baulig
{
	public class X
	{
		public int A;
	}

	public class Y
	{
		public int B;
	}

	public struct SomeStruct<R>
	{
		public int A;
		public R Data;

		public SomeStruct (int a, R data)
		{
			this.A = a;
			this.Data = data;
		}

		public void Invocation (SomeStruct<R> arg)
		{
			Console.WriteLine ("INVOCATION: {0} {1} - {2} {3}", A, Data, arg.A, arg.Data);
		}
	}

	public class Foo<T>
		where T : new ()
	{
		public readonly T Data;

		public Foo ()
		{
			Data = new T ();
		}

		public void Hello ()
		{
			Console.WriteLine (Data);
			SomeStruct<T> a = new SomeStruct<T> (5, Data);
			Console.WriteLine (a);
		}
	}

	class GenericTest
	{
		static void Main ()
		{
			Foo<X> x = new Foo<X> ();
			Foo<Y> y = new Foo<Y> ();

			x.Data.A = 5;
			y.Data.B = 9;

			x.Hello ();
			y.Hello ();
		}
	}
}