Click here to Skip to main content
15,892,809 members
Home / Discussions / C#
   

C#

 
Questionc# Pin
Member 1312071627-Jun-19 22:49
Member 1312071627-Jun-19 22:49 
AnswerRe: c# Pin
OriginalGriff27-Jun-19 23:30
mveOriginalGriff27-Jun-19 23:30 
GeneralRe: c# Pin
Eddy Vluggen28-Jun-19 2:03
professionalEddy Vluggen28-Jun-19 2:03 
GeneralRe: c# Pin
OriginalGriff28-Jun-19 2:23
mveOriginalGriff28-Jun-19 2:23 
GeneralRe: c# Pin
Eddy Vluggen28-Jun-19 2:39
professionalEddy Vluggen28-Jun-19 2:39 
AnswerRe: c# Pin
Gerry Schmitz28-Jun-19 6:51
mveGerry Schmitz28-Jun-19 6:51 
QuestionBase toString not printing to console Pin
Member 1451443227-Jun-19 5:42
Member 1451443227-Jun-19 5:42 
AnswerRe: Base toString not printing to console Pin
Dave Kreskowiak27-Jun-19 5:59
mveDave Kreskowiak27-Jun-19 5:59 
Get to know the debugger. It would easily help you out with this.
C#
public string ToStirng()
        {
            return ("Name: " + getName()
                    +"\n"
                    +"Age: " + getAge()
                    +"\n"
                    +"Breed: " + getBreed()
                    +"\n"
                    +"Fur Color: " + getFurColor());
        }

Why do you have all these get and set methods? You could easily just replace them with properties:
C#
public abstract class Animal
{
    public string Name { get; set; }
    public int Age { get; set; }
    public string Breed { get; set; }
    public string FurColor { get; set; }

    public Animal(string name, int age, string breed, string furColor)
    {
        Name = name;
        Age = age;
        Breed = breed;
        FurColor = furColor;
    }

    public abstract void Sound();

    public override string ToString()
    {
        return $"Name: {Name}\nAge: {Age}\nBreed: {Breed}\nFur Color: {FurColor}";
    }
}


GeneralRe: Base toString not printing to console Pin
Member 1451443227-Jun-19 6:14
Member 1451443227-Jun-19 6:14 
AnswerRe: Base toString not printing to console Pin
OriginalGriff27-Jun-19 6:07
mveOriginalGriff27-Jun-19 6:07 
GeneralRe: Base toString not printing to console Pin
Member 1451443227-Jun-19 6:12
Member 1451443227-Jun-19 6:12 
GeneralRe: Base toString not printing to console Pin
OriginalGriff27-Jun-19 6:24
mveOriginalGriff27-Jun-19 6:24 
QuestionNew to Coding New to Code Project Pin
Member 1451100824-Jun-19 10:11
Member 1451100824-Jun-19 10:11 
AnswerRe: New to Coding New to Code Project Pin
Eddy Vluggen24-Jun-19 11:19
professionalEddy Vluggen24-Jun-19 11:19 
GeneralRe: New to Coding New to Code Project Pin
Mycroft Holmes24-Jun-19 13:10
professionalMycroft Holmes24-Jun-19 13:10 
GeneralRe: New to Coding New to Code Project Pin
Eddy Vluggen24-Jun-19 13:27
professionalEddy Vluggen24-Jun-19 13:27 
AnswerRe: New to Coding New to Code Project Pin
Mycroft Holmes24-Jun-19 13:11
professionalMycroft Holmes24-Jun-19 13:11 
AnswerRe: New to Coding New to Code Project Pin
Ger Hayden24-Jun-19 21:51
Ger Hayden24-Jun-19 21:51 
AnswerRe: New to Coding New to Code Project Pin
Richard MacCutchan24-Jun-19 22:24
mveRichard MacCutchan24-Jun-19 22:24 
AnswerRe: New to Coding New to Code Project Pin
#realJSOP26-Jun-19 6:32
mve#realJSOP26-Jun-19 6:32 
AnswerRe: New to Coding New to Code Project Pin
Gerry Schmitz26-Jun-19 8:53
mveGerry Schmitz26-Jun-19 8:53 
QuestionWhat is wrong with my code in Visual Studios Pin
Member 1451091724-Jun-19 7:46
Member 1451091724-Jun-19 7:46 
AnswerRe: What is wrong with my code in Visual Studios Pin
Richard Deeming24-Jun-19 8:39
mveRichard Deeming24-Jun-19 8:39 
GeneralRe: What is wrong with my code in Visual Studios Pin
Member 1451091724-Jun-19 9:12
Member 1451091724-Jun-19 9:12 
AnswerRe: What is wrong with my code in Visual Studios Pin
OriginalGriff24-Jun-19 19:56
mveOriginalGriff24-Jun-19 19:56 

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.