Jo Shields a575963da9 Imported Upstream version 3.6.0
Former-commit-id: da6be194a6b1221998fc28233f2503bd61dd9d14
2014-08-13 10:39:27 +01:00

18 lines
338 B
C#

//-- ex-nullable-sqrt
using System;
class MyTest {
public static int? Sqrt(int? x) {
if (x.HasValue && x.Value >= 0)
return (int)(Math.Sqrt(x.Value));
else
return null;
}
public static void Main(String[] args) {
// Prints :2:::
Console.WriteLine(":{0}:{1}:{2}:", Sqrt(5), Sqrt(null), Sqrt(-5));
}
}