linux-packaging-mono/mcs/tests/test-nameof-05.cs

67 lines
1023 B
C#
Raw Normal View History

// Compiler options: -warnaserror
using System;
public class Person
{
public Car MyCar { get; set; }
}
public class Car
{
public int Year { get; set; }
}
enum EE
{
K
}
public class MainClass
{
class Nested
{
}
public static Person MyPerson1 { get; } = new Person();
public static Person MyPerson2 = new Person();
public const Person MyPerson3 = null;
public static event Action Act = null;
public static dynamic BBB = null;
public static int Main ()
{
string name;
name = nameof (MyPerson1.MyCar.Year);
if (name != "Year")
return 1;
name = nameof (MyPerson2.MyCar.Year);
if (name != "Year")
return 2;
name = nameof (MyPerson3.MyCar.Year);
if (name != "Year")
return 3;
name = nameof (Act.Method.MemberType);
if (name != "MemberType")
return 4;
name = nameof (BBB.A.B.C);
if (name != "C")
return 5;
name = nameof (EE.K.ToString);
if (name != "ToString")
return 6;
name = nameof (int.ToString);
if (name != "ToString")
return 7;
return 0;
}
}