학교에서 공개 무시 문자열을 사용하도록 요청합니다. 나는 이런 식으로 뭔가를하고 싶은 :public override string more returns
lbl_Name.Text = ToString(*Field: Naam from class Gebruikerklasse*)
lbl_Surname.Text = ToString(*Field: Achternaam from class Gebruikersklasse*)
내 클래스의 여러 필드를 가지고,하지만 난 그들 중 몇 가지를 반환합니다. 다른 방법이 필요합니까 아니면 하나의 방법으로 만 수행 할 수 있고 if 문과 부울을 사용하여 더 많은 수익을 올릴 수 있습니까?
이 내가 지금 무엇을 가지고 :
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BurnThatFat
{
class Gebruikerklasse
{
public string Naam;
public string Achternaam;
public int Leeftijd;
public string Geslacht;
public int Huidiggewicht;
public int Streefgewicht;
public string Gebruikersnaam;
public string Wachtwoord;
public override string ToString()
{
return Naam;
}
// I want to use the same method again but this time for another field.
public override string ToString()
{
return Gebruikersnaam;
}
}
}
당신이 * –
을하고 싶지 그리고 당신은 지금 읽으면 무슨 * 명확하지? @ L.B – Gigitex
컴파일러로 하여금 합리적인 지시없이 무엇을하고 싶은지를 알아 내고 싶다면 ... 분명히 많은 코드를 작성하는 이유는 무엇인가? :) "C# method overloads"를 읽으면 언어에서 의미가있는 것을 볼 수 있습니다. –