Format1 클래스에 9 개의 문자열이 있습니다.이 클래스는 Format2 클래스에서 볼 수있는 다른 유형으로 변환하려고하지만 3 개의 문자열은 여전히 문자열 유형으로 유지됩니다. 내가 만족 스러울 때까지 나는 그들과 놀기 시작했다.C# 메서드를 사용하여 객체 및 클래스에 액세스
내 Form1.cs 코드에서 볼 수 있듯이 버튼 클릭 이벤트에서 실제로하고 싶은 것은 getConvert() 메서드를 호출하여 모든 것을 처리하도록하는 것입니다. Apperantly 나는 뭔가를 놓치고있다. 나는 모든 것을 불러 내기 위해 나의 추한 6 줄을 사용해야한다.
코드에서 내 의견에 제 작동하지 않는 시도가 표시됩니다. 이번에 내가 뭘 잘못 했니? https://mega.co.nz/#!64QzERRR!Qit9SDZQ7kW7rNCAUUHHDRZUUvZY9z0ukgfuqVt00mE
public class Format1
{
public string Name { get; set; }
public string Year { get; set; }
public string Director { get; set; }
public string AverageRating { get; set; }
public string LeadingActor1 { get; set; }
public string LeadingActor2 { get; set; }
public string LeadingActor3 { get; set; }
public string Language { get; set; }
public string ImdbLink { get; set; }
}
public class Format2 : Format1
{
public int Year { get; set; }
public int AverageRating {get; set;}
public string LeadingActors { get; set; }
public bool IsInEnglish { get; set; }
public bool HasImdbLink { get; set; }
public Format2 getConvert()
{
Format2 converted = new Format2();
//converted.Name = textBox1.Text;
//textBox18.Text = converted.Name;
converted.Name = this.Name;
converted.Director = this.Director;
converted.ImdbLink = this.ImdbLink;
return converted;
}
}
namespace as3_DVDproject
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
Format2 converted = new Format2();
private void label1_Click(object sender, EventArgs e)
{
}
private void label8_Click(object sender, EventArgs e)
{
}
private void label9_Click(object sender, EventArgs e)
{
}
private void okButton_Click(object sender, EventArgs e)
{
//converted.getConvert();
converted.Name = textBox1.Text;
textBox18.Text = converted.Name;
converted.Director = textBox3.Text;
textBox16.Text = converted.Director;
converted.ImdbLink = textBox9.Text;
textBox10.Text = converted.ImdbLink;
}
}
}
고맙습니다! 이것은 내가 찾고 있던 것이 었습니다. 나는 그것으로 실험하려고 노력할 것이다^_^ –