Może to pytanie jest głupie, ale w mojej konkretnej sytuacji chcę uzyskać nazwę instancji, więc o co mi chodzi:Uzyskaj nazwę instancji C#
class Student
{
private string name {get; private set;}
public Student(string name)
{
this.name = name
}
public getInstanceName()
{
//some function
}
}
Więc kiedy zrobić student
Student myStudent = new Student("John");
, że to głupie, ale chcę to
myStudent.getInstanceName(); // it should return 'myStudent'
Więc chcesz nazwę zmiennej? –
Po co tego chcesz? to nie ma sensu. –
Czy chcesz nazwę zmiennej e..g 'myStudent' lub nazwę ucznia, np. 'John'? – eandersson