Note that there are some explanatory texts on larger screens.

plurals
  1. POc# access objects and classes using method
    primarykey
    data
    text
    <p>I have 9 strings in Format1 class, that I want convert into different types as seen in Format2 class, However 3 strings will still remain as string types. I decided to start playing with them until I got a code I was happy with.</p> <p>As you see in my Form1.cs code all I want to do really upon the button click event is to call the getConvert() method and let it handle everything. Apperantly I am missing out on something. I have to use my ugly 6 lines to call everything up.</p> <p>You see my non working attemps in my comments in the code. What did I do wrong this time ??</p> <p>You can also grab my source here: <a href="https://mega.co.nz/#!64QzERRR!Qit9SDZQ7kW7rNCAUUHHDRZUUvZY9z0ukgfuqVt00mE" rel="nofollow">https://mega.co.nz/#!64QzERRR!Qit9SDZQ7kW7rNCAUUHHDRZUUvZY9z0ukgfuqVt00mE</a></p> <pre><code>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; } } } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload