我在 C# winForms 上使用 StreamWriter
如您所见,我需要将信息写给“作家”。
我做错了什么,因为“作家”字段有语法错误吗?
我收到一条消息说:
“‘writer’是一个‘field’,但它被用作‘type’”
请问有什么想法吗?我的代码在下面
class Booking
{
//what other details do you need to save at the end?...
public Show bookedShow { get; private set; }
public Seat selectedSeat { get; private set; }
public Show selectedShow { get; private set; }
public Seat finalPrice { get; private set; } //hasnt been defined yet, but this would be the amount of seats selected * the Price
//i will also need customer details which are:
public dateAndTime dateTime { get; private set; }
public Customer custName { get; private set; }
public Customer custAddress { get; private set; }
public Customer custTelephone { get; private set; }
System.IO.StreamWriter writer = new System.IO.StreamWriter(@"C:\BookingInfo.txt"); //open the file for writing.
writer.Write(dateTime.ToString()); //write the current date to the file. change this with your date or something.
writer.write(bookedShow.ToString());
writer.write(selectedShow.ToString());
writer.write(selectedSeat.ToString());
writer.write(finalPrice.ToString());
writer.write(custName.ToString());
writer.write(custAddress.ToString());
writer.write(custTelephone.ToString());
writer.Close();
}