a575963da9
Former-commit-id: da6be194a6b1221998fc28233f2503bd61dd9d14
18 lines
338 B
C#
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));
|
|
}
|
|
}
|