I can’t find the source of error in this file

Updated on December 28, 2017 in [A] C# .Net
Share on Facebook0Tweet about this on TwitterShare on Google+0Share on Reddit0
1 on December 27, 2017

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;

namespace Rextester
{
public class ForestAnimals
{
public char Animal;
public char Name;
public char Mood;

public void TypeOfAnimal()

{
Console.WriteLine(” The animal is: ” + Animal + ” and his name is ” + Name + ” .He is ” + Mood);
}
}

public class Input
{
public static void Main(string[] args)

{
var input = new ForestAnimals();
input.Animal = Convert.ToChar(“Doggo”);
input.Name = Convert.ToChar(“John Cena”);
input.Mood = Convert.ToChar(“Happy”);
input.TypeOfAnimal();
}
}
}

  • Liked by
Reply
0 on December 28, 2017

The variable char is a character like ‘a’ or ‘§’. you can’t use char for words like “doggo”. Therefor you should use the variable string.

example:

public string Animal;

input.Animal = Convert.ToString(“Doggo”);

  • Liked by
Reply
Cancel