Saturday, 7 September 2013

parsing objects into methods

parsing objects into methods

i'm trying to get this code to work.. i've been googling for over an hour
already but i cant seem to get this code to work: (i'm totally new to C#)
i think it has something to do with the method print. i get the following
error:
type 'object' does not contain a definition for 'Voornaam' and no
extension method 'Voornaam' of type 'object' could be found
// naam: Dylan Westra
// klas: i1b
// datum 07-09-2013
using System;
namespace les2
{
public class client
{
public string Voornaam;
public string Achternaam;
public string Adres;
public int Salaris;
public client (string voornaam, string achternaam, string adres,
int salaris)
{
Voornaam = voornaam;
Achternaam = achternaam;
Adres = adres;
Salaris = salaris;
}
public void print (object obje)
{
Console.WriteLine (obje.Voornaam + " " + obje.Achternaam + " "
+ obje.Adres + " " + obje.Salaris);
}
}
class MainClass
{
public static void Main (string[] args)
{
client gegevens1 = new client("Dylan", "Westra", "Rozengracht
34", 1200);
//client gegevens2 = new client("Rosa", "de Gruijter",
"Rozengracht 34", 200);
client.print(gegevens1);
}
}
}

No comments:

Post a Comment