Hi, I need some help, I am still newbie in this OOP,I already created the employee class in console app,but what i want is to use my employee class in windows forms,how can i use this employee class in windows forms application ?...I tried searching in google but i have no luck to find great examples for this.I hope someone can help me on this or give some simple example with windows format that deals OOP.

Thank you in advance :)

You can't use *.cpp and *.h files that you created in the console program in C++ language with C#. You will have to modify and translate them into C# language. For example Employee.cpp will become Employee.cs and look something like this:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace WindowsFormsApplication1
{
    class Employee
    {
        public Employee() {}

        private System.String name;

    }
}

Hi Ancient Dragon,This is just simple class employee...How do i use this in my button add employee so that when i am going to press the button add it will save to my database,just assume that i am connected to the database.can you please show me simple code for this.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace OOP
{
    public class Employee
    {
        private string firstname;
        private string lastname;
        private int age;



        public Employee() { }

        public string Firstname
        {
          get { return firstname; }
          set { firstname = value; }
        }

        public string Lastname
        {
            get { 
                   return lastname;
            }
            set {
                lastname = value;
            }
        }

        public int Age
        {
            get { 
                  return age;
             }
            set { 
                age = value;
            }
        }

        public  override string ToString()
        {
             return string.Format("Firstname:{0}\nLastname:{1}\nAge:{2}",firstname,lastname,age);
        }


    }
}

Thank you in avdvance

This article has been dead for over six months. Start a new discussion instead.