For example I want to log the Name
value every time it changes.
using System;
class Data {
public string Name;
public Data(string name) {
Name = name;
}
}
public class Test
{
public static void Main()
{
Data data = new("foo");
object name = typeof(Data).GetField("Name").GetValue(data);
Console.WriteLine(name);
}
}
Aucun commentaire:
Enregistrer un commentaire