How do i get the data to appear line after line in notepad
and with the dashes in the phone number
that my code
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Friends
{
class WriteFriendRecord
{
static void Main(string[] args)
{
Console.WriteLine("Enter your friend's details: ");
Friends.Friend f = new Friends.Friend();
Console.Write("Frist Name: ");
string fn = Console.ReadLine();
Console.Write("Last Name: ");
string ln = Console.ReadLine();
Console.Write("Phone Number: ");
long pn = Convert.ToInt64(Console.ReadLine());
Console.Write("Month of the Birth: ");
string mb = Console.ReadLine();
Console.Write("Day of the Birth: ");
int d = Convert.ToInt32(Console.ReadLine());
f.setName(fn, ln);
f.setPhoneNum(pn);
f.setBirthDate(mb, d);
System.IO.File.AppendAllText("F:/CSIS115c/WriteFriendRecord/Friends/bin/Debug/FriendsData.txt", f.ToString());
Console.WriteLine("Record saved successfully");
Console.WriteLine();
Console.Read();
}
}
}
[B]Friend Class
[/B]
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Friends
{
class Friend
{
private string firstName;
private string lastName;
private long phoneNum;
private string month;
private int day;
public Friend()
{
}
public Friend(string f, string l, long num, string m, int d)
{
firstName = f;
lastName = l;
phoneNum = num;
month = m;
day = d;
}
public void setBirthDate(string m, int d)
{
month = m;
day = d;
}
public void setName(string f, string l)
{
firstName = f;
lastName = l;
}
public void setPhoneNum(long num)
{
phoneNum = num;
}
public void getFriend()
{
Console.WriteLine("First Name: " + firstName);
Console.WriteLine("Last Name: " + lastName);
Console.WriteLine("phone Number: " + phoneNum);
Console.WriteLine("DateOfBirth: " + month + ", " + day);
}
public override string ToString()
{
return String.Format("{0} {1} {2} {3} {4}\n", firstName, lastName, phoneNum, month, day);
}
}
}