매개 변수에 와일드 카드를 사용할 수 있습니까? TextLine1, TextLine2, TextLine3 및 TextLine 4 속성에 대해 반복되는이 코드가 있습니다. 번호를 와일드 카드로 바꿀 수 있으며 사용자 입력을 기반으로 숫자를 전달할 수 있습니까?개체에서 와일드 카드가 작동합니까?
TextLine1, TextLine2, TextLine3 및 TextLine 4는 ReportHeader 클래스의 속성입니다.
public Control returnTextLine(ReportHeader TextLineObj,int i)
{
System.Windows.Forms.Label lblTextLine = new System.Windows.Forms.Label();
lblTextLine.Name = TextLineObj.**TextLine1**.Name;
lblTextLine.Font = TextLineObj.**TextLine1**.Font;
lblTextLine.ForeColor = TextLineObj.**TextLine1**.ForeColor;
lblTextLine.BackColor = TextLineObj.**TextLine1**.BackgroundColor;
lblTextLine.Text = TextLineObj.**TextLine1**.Text;
int x = TextLineObj.**TextLine1**.x;
int y = TextLineObj.**TextLine1**.y;
lblTextLine.Location = new Point(x, y);
return lblTextLine;
}
제발 도와주세요
...
내가 공공 ReadOnlyCollection TextLines {얻을 "추가에 대한 정의가 포함되어 있지 않습니다"라는 {TextLine1, TextLine2, TextLine3, TextLine4}에서 또한 새로운 키워드에 오류가 발생하고있어, 개인 집합; } public ReportHeader() { TextLines = new ReadOnlyCollection {TextLine1, TextLine2}; } –
NewBie
@NewBie : 내 대답이 업데이트되었습니다. 다시 시도하십시오. –