C# nybegynder
Hejsa, jeg er indtil videre en nybegynder i C# programmering. Er der nogen der kan fortælle mig lidt om hvad der sker i nedenstående kodelinier. På forhånd tak.private void updateContact() {
if (activeObject == null) return;
activeObject.Navn = txtNavn.Text;
activeObject.Stilling = txtStilling.Text;
activeObject.Virksomhed = txtVirksomhed.Text;
activeObject.Afdeling = txtAfdeling.Text;
activeObject.Tlfnr = txtTlf.Text;
activeObject.Mobilnr = txtMobil.Text;
activeObject.Email = txtEmail.Text;
activeObject.Adresse = txtAdresse.Text;
activeObject.Postnr = int.Parse(txtPost.Text);
activeObject.Persist();
}
private void updateFields() {
if (activeObject == null) return;
txtNavn.Text = activeObject.Navn;
txtStilling.Text = activeObject.Stilling;
txtVirksomhed.Text = activeObject.Virksomhed;
txtKompetence.Text = activeObject.Kompetencer.Count.ToString();
txtAfdeling.Text = activeObject.Afdeling;
txtTlf.Text = activeObject.Tlfnr;
txtMobil.Text = activeObject.Mobilnr;
txtEmail.Text = activeObject.Email;
txtAdresse.Text = activeObject.Adresse;
txtPost.Text = activeObject.Postnr.ToString();
string kompetencer = "";
foreach (Kompetence k in this.activeObject.Kompetencer)
kompetencer += k.ToString() +", ";
if (kompetencer.Length > 30)
kompetencer = kompetencer.Remove(30);
txtKompetence.Text = kompetencer + "...";
string logText = "";
foreach (LogEntry le in this.activeObject.LogEntries.Sort())
{
logText += "*********** \r\n";
logText += le.Time.ToString() + "\r\n";
logText += le.Text + "\r\n";
logText += "\r\n";
}
log.Text = logText;
}
public object ActiveObject {
get {
return this.activeObject;
}
set {
this.activeObject = value as Kontaktperson;
this.updateFields();
}
}
}
}