【发布时间】:2018-01-10 02:19:57
【问题描述】:
我正在使用 Visual Studio 2015,我正在练习 C#。 用户输入信息后如何在控制台显示列表? 我可能做错了,我还在学习 C#。一旦我输入了所有信息,我如何让控制台显示收集的信息?我有一个固定的总收入数字,我不知道如何更改它,以便用户可以输入任何数字并计算它,(仍在努力)欢迎任何建议、链接、视频。我在看一些复数教程,但似乎没有展示如何做到这一点。
//My first program
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace PracticeProgram
{
public class Program
{
public static void Main(string[] args)
{
List<Person> myContacts = new List<Person>();
//You could loop to collect developers data
for (int i = 0; i < 4; i++)
{
Console.WriteLine("Welcome developer, enter your name to continue");
string name = Console.ReadLine();
Console.WriteLine("Hello, " + name);
Console.WriteLine("enter your address");
string address = Console.ReadLine();
Console.WriteLine(address);
Console.WriteLine("enter your monthly income");
double GrossMonthlyPay = 10000;
Console.WriteLine(GrossMonthlyPay);
Console.WriteLine("your tax deduction set at 7% is ");
double taxes = (0.07);
Console.WriteLine(taxes = GrossMonthlyPay * taxes);
Console.Write("\nPress any key to continue...");
Console.ReadLine();
myContacts.Add(new Person(name, address, GrossMonthlyPay, taxes));
}
}
}
internal class Person
{
private string address;
private double grossMonthlyPay;
private string name;
private double taxes;
public Person(string name, string address, double grossMonthlyPay, double taxes)
{
this.name = name;
this.address = address;
this.grossMonthlyPay = grossMonthlyPay;
this.taxes = taxes;
}
internal static Person ReadFromCSV(string line)
{
throw new NotImplementedException();
}
internal void SerializeToCSV(string v)
{
throw new NotImplementedException();
}
}
}
【问题讨论】:
标签: c# visual-studio-2015