Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9178327
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T17:31:32+00:00 2026-06-17T17:31:32+00:00

I have 9 strings in Format1 class, that I want convert into different types

  • 0

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.

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.

You see my non working attemps in my comments in the code. What did I do wrong this time ??

You can also grab my source here:
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;

        }
    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T17:31:33+00:00Added an answer on June 17, 2026 at 5:31 pm

    The more object oriented pattern would be to either add a constructor to Format2 that takes a Format1, or give Format2 a static method that takes a Format1 and returns a Format2. The actual mapping code doesn’t really look all that verbose to me though, you could drop it in either one of those places.

    private void okButton_Click(object sender, EventArgs e)
    {
        Format1 one = new Format1(textBox1.Text, converted.Name, textBox3.Text, converted.Director);
        Format2 two = new Format2(one);
    }
    

    You want the objects to know how to construct themselves rather than building them in the form.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an integer which I want to convert to class Date . I
I have strings that use simple_format so they always have p tags surrounding them.
I have a File that COntains Strings in This Format: ACHMU)][2:s,161,(ACH Payment Sys Menus
I have a date in String format, mm/dd/yyyy I want to convert this to
I have a class that creates a static array of all properties, using a
I want to convert the JSON output of the Shopify API call into an
I have created a class (ConflictingBooking) that contains fields for various information in regards
I have an ImageHandler class that I am using to retrieve photos from an
I have a C++ class that is the frontend for a logging system. Its
I have a class Store.java where I simply store 2 strings and an integer.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.