In: Computer Science
I keep getting this error "LetterDemo.cs(21,14): error CS1519: Unexpected symbol `string' in class, struct, or interface member declaration"
Can someone please help me.
Here is my code:
using static System.Console;
class LetterDemo
{
static void Main()
{
Letter letter1 = new Letter();
CertifiedLetter letter2 = new CertifiedLetter();
letter1.Name = "Electric Company";
letter1.Date = "02/14/18";
letter2.Name = "Howe and Morris, LLC";
letter2.Date = "04/01/2019";
letter2.TrackingNumber = "i2YD45";
WriteLine(letter1.ToString());
WriteLine(letter2.ToString() +
" Tracking number: " + letter2.TrackingNumber);
}
}
class Letter
{
pubic string Name {get; set;}
pubic string Date {get; set;}
public new string ToString()
{
return(GetType() + " To: " + Name + " Date mailed : " + Date);
}
}
class CertifiedLetter : Letter
{
public string TrackingNumber {get; set;}
}
C# Program:
using static System.Console;
class LetterDemo{
static void Main() {
Letter letter1 = new Letter();
CertifiedLetter letter2 = new CertifiedLetter();
letter1.Name = "Electric Company";
letter1.Date = "02/14/18";
letter2.Name = "Howe and Morris, LLC";
letter2.Date = "04/01/2019";
letter2.TrackingNumber = "i2YD45";
WriteLine(letter1.ToString());
WriteLine(letter2.ToString() + " Tracking number: " + letter2.TrackingNumber);
}
}
class Letter
{
public string Name {get; set;}
public string Date {get; set;}
public new string ToString()
{
return(GetType() + " To: " + Name + " Date mailed : " + Date);
}
}
class CertifiedLetter : Letter
{
public string TrackingNumber {get; set;}
}
Output:
NOTE: You did very small mistake
pubic string Name {get; set;} ==> pubic is nothing in programming language, should be public
pubic string Date {get; set;} ==> same as above
Thumbs Up Please !!!