Click here to Skip to main content
15,890,946 members
Home / Discussions / C#
   

C#

 
QuestionSelf referencing loop detected for property with type ... Pin
AtaChris22-Apr-24 9:02
AtaChris22-Apr-24 9:02 
AnswerRe: Self referencing loop detected for property with type ... Pin
Richard Andrew x6422-Apr-24 12:37
professionalRichard Andrew x6422-Apr-24 12:37 
AnswerRe: Self referencing loop detected for property with type ... Pin
AtaChris22-Apr-24 21:30
AtaChris22-Apr-24 21:30 
AnswerRe: Self referencing loop detected for property with type ... Pin
Dave Kreskowiak22-Apr-24 13:43
mveDave Kreskowiak22-Apr-24 13:43 
GeneralRe: Self referencing loop detected for property with type ... Pin
AtaChris22-Apr-24 21:28
AtaChris22-Apr-24 21:28 
GeneralRe: Self referencing loop detected for property with type ... Pin
Dave Kreskowiak23-Apr-24 4:48
mveDave Kreskowiak23-Apr-24 4:48 
QuestionHow to print the property values of an object to a file/console ? Pin
AtaChris22-Apr-24 8:51
AtaChris22-Apr-24 8:51 
AnswerRe: How to print the property values of an object to a file/console ? Pin
Dave Kreskowiak22-Apr-24 13:49
mveDave Kreskowiak22-Apr-24 13:49 
The Student class should NOT CARE AT ALL about outputting anything to the console or other output. It should be just limited to managing the data for a single Student.

One problem I see if your Student class should expose its data in public properties, not fields.

Having said that, whatever UI code is using this class in some way would be responsible for the presentation. To get the properties in the format you specified in your question, the easiest way to return the string would be to override the Student class ToString method and build the formatted string to return to the caller:
C#
public class Student  
{  
    public int ID { get; set; } = 1234;
    public string Name { get; set; } = "gustav";
    public bool State { get; set; } = true;
.
.
.
    public override string ToString()
    {
        string result = $"{ID}\r\n{Name}\r\n{State}";

        return result;
    }
}


GeneralRe: How to print the property values of an object to a file/console ? Pin
AtaChris22-Apr-24 21:23
AtaChris22-Apr-24 21:23 
GeneralRe: How to print the property values of an object to a file/console ? Pin
Pete O'Hanlon22-Apr-24 22:44
mvePete O'Hanlon22-Apr-24 22:44 
GeneralRe: How to print the property values of an object to a file/console ? Pin
Dave Kreskowiak23-Apr-24 4:10
mveDave Kreskowiak23-Apr-24 4:10 
QuestionHow to identify Key Combinations ? Pin
AtaChris15-Apr-24 6:26
AtaChris15-Apr-24 6:26 
AnswerRe: How to identify Key Combinations ? Pin
Dave Kreskowiak15-Apr-24 6:35
mveDave Kreskowiak15-Apr-24 6:35 
QuestionHow to send property values via eventhandler ? Pin
AtaChris7-Apr-24 7:41
AtaChris7-Apr-24 7:41 
AnswerRe: How to send property values via eventhandler ? Pin
OriginalGriff7-Apr-24 20:23
mveOriginalGriff7-Apr-24 20:23 
GeneralRe: How to send property values via eventhandler ? Pin
AtaChris15-Apr-24 6:46
AtaChris15-Apr-24 6:46 
GeneralRe: How to send property values via eventhandler ? Pin
OriginalGriff15-Apr-24 19:09
mveOriginalGriff15-Apr-24 19:09 
QuestionRead information from serial port in Mathlab format Pin
Victor Gonzalez 20245-Apr-24 9:43
Victor Gonzalez 20245-Apr-24 9:43 
AnswerRe: Read information from serial port in Mathlab format Pin
Richard Andrew x645-Apr-24 11:01
professionalRichard Andrew x645-Apr-24 11:01 
GeneralRe: Read information from serial port in Mathlab format Pin
Victor Gonzalez 20245-Apr-24 12:26
Victor Gonzalez 20245-Apr-24 12:26 
AnswerRe: Read information from serial port in Mathlab format Pin
jschell5-Apr-24 12:20
jschell5-Apr-24 12:20 
GeneralRe: Read information from serial port in Mathlab format Pin
Victor Gonzalez 20245-Apr-24 12:28
Victor Gonzalez 20245-Apr-24 12:28 
GeneralRe: Read information from serial port in Mathlab format Pin
Richard MacCutchan5-Apr-24 22:44
mveRichard MacCutchan5-Apr-24 22:44 
GeneralRe: Read information from serial port in Mathlab format Pin
Victor Gonzalez 20245-Apr-24 23:22
Victor Gonzalez 20245-Apr-24 23:22 
GeneralRe: Read information from serial port in Mathlab format Pin
Richard MacCutchan5-Apr-24 23:41
mveRichard MacCutchan5-Apr-24 23:41 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.