So here is the thing. I have assignment in c# which says that i have string:
string text = "John.Davidson/Belgrade Michael.Barton/Krakow Ivan.Perkinson/Moscow".
I need to split this string to get name, surname and city... and then i need to create 3 objects type Person. That 3 objects I need to put in 1 Person[ ] array, and in the end i need to go through that array and print this peoples info. Result should look like this:
John Davidson Belgrade
Michael Barton Krakow
Ivan Perkinson Moscow
I tried to create a code that would work but i couldn't finish. I succeeded to some point but i dont know how to finish. I don't know if i did it right but if i did i dont know how to connect this splitted string with class which i wrote. Please help.
Here is the code:
{
string text = "John.Davidson/Belgrade Michael.Barton/Krakow Ivan.Perkinson/Moscow ";
string[] strings = text.Split(new char[] {'.','/',' '});
foreach(string s in strings)
{
Console.WriteLine(s);
}
}
class Person
{
public string Name;
public string Surname;
public string City;
public Person(string name, string surname, string city)
{
Name = name;
Surname = surname;
City = city;
}
}