Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gtest-462.cs « tests « mcs - github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 74bd6b743fd81c7e080844c03f4145003754babd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
using System;

class Program
{
	public static int Main ()
	{
		Tester<int> t = new Tester<int> ();
		int r = t.Get (333);
		Console.WriteLine (r);
		if (r != 333)
			return 1;

		r = t.Get (222.12);
		Console.WriteLine (r);
		if (r != 0)
			return 2;

		return 0;
	}

	class Tester<T> where T : struct, IConvertible
	{
		public T Get (object data)
		{
			var val = data;
			if (val is T)
				return (T) val;
			return default (T);
		}
	}
}