Laden...

Forenbeiträge von Michaell Ingesamt 3 Beiträge

13.06.2021 - 00:37 Uhr

Hier habe ich einfache über CSV einzulesen geschrieben:


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;

namespace dataCSV
{
    class Program
    {
        static void Main(string[] args)
        {
            string path = @"C:\Users\Michael\Desktop\person.csv";

            if (!File.Exists(path))
            {
                string[] createText = { "Hello", "And", "Welcome" };
                File.WriteAllLines(path, createText);
            }

            string appendText = "This is extra Text" + Environment.NewLine;
            File.AppendAllText(path, appendText);

            string[] readText = File.ReadAllLines(path);

            foreach (string s in readText)
            {
                Console.WriteLine(s);
            }
        }
    }
}

Aber jetzt will ich die Klasse von Person erschaffen, dass die Eigenschaften haben muss: Name, Vorname, Alt usw.
Diese Klasse muss mit Klassendiagramm schreiben werden.
Die Frage ist: Wie kann ich meine Codes in Klassendiagramm mit Eigenschaften schreiben?

09.06.2021 - 12:48 Uhr

Hallo Zusammen,
aufgrund bin ich ganz Anfänger in C#, versuche ich diese Aufgabe mit Klassendiagramm zu lösen. Es ist sehr wichtig, dass diese Aufgabe mit Klassendiagramm schreiben.
Hier ist Hinweis auch:

// path to the csv file



            if (path == null) path = "persons.csv";

            string[] lines = System.IO.File.ReadAllLines(path);
            //for skipping header
            lines = lines.Skip(1).ToArray();

            foreach (string line in lines)
            {
                string[] column = line.Split(',');
                // foreach (string column in columns) {

                // Do something        
                string lastname = column[0];
                string firstname = column[1];
                int age = Convert.ToInt32(column[2]);