Click here to Skip to main content
15,883,848 members
Home / Discussions / C#
   

C#

 
GeneralRe: C# with several proejct folders using linq to sql Pin
classy_dog9-Sep-12 8:51
classy_dog9-Sep-12 8:51 
GeneralRe: C# with several proejct folders using linq to sql Pin
Dave Kreskowiak9-Sep-12 13:27
mveDave Kreskowiak9-Sep-12 13:27 
Questionmdiparent_clickevent dosnt work right Pin
mohammadkaab8-Sep-12 0:28
mohammadkaab8-Sep-12 0:28 
AnswerRe: mdiparent_clickevent dosnt work right Pin
Eddy Vluggen8-Sep-12 4:46
professionalEddy Vluggen8-Sep-12 4:46 
QuestionDisplay Live TV Pin
Jassim Rahma7-Sep-12 22:28
Jassim Rahma7-Sep-12 22:28 
AnswerRe: Display Live TV Pin
Eddy Vluggen8-Sep-12 4:41
professionalEddy Vluggen8-Sep-12 4:41 
QuestionHow to retrieve dell drac ip's via c sharp? Pin
turbosupramk37-Sep-12 10:28
turbosupramk37-Sep-12 10:28 
QuestionGenerics Problems Pin
Kevin Marois7-Sep-12 7:11
professionalKevin Marois7-Sep-12 7:11 
I'm refactoring a WinForms project. I have 2 forms that do the same thing, except the data entities passed in are slightly different, so the guy who wrote them decided to duplicate the forms instead of making one form that works for both. So I'm refactoring them.

Assume I have these 2 entites:
public class Entity1
{
    public string SomeProperty { get; set; }
    public string Name { get; set; }
}
public class Entity2
{
    public string SomeProperty { get; set; }
    public string Caption { get; set; }
}


In the CTOR of the form I have:

public partial class Form1<T> : Form
{
    T entity;

    public Form1()
    {
        InitializeComponent();

        entity = (T)Activator.CreateInstance(typeof(T));

    }
}


The problem is I now need to set properties on the object passed in. In most cases the 2 objects have the same name properties, but ther are differences.

What is the right way to work with this object? Seems like I have no choice but to cast.

Thanks
If it's not broken, fix it until it is

AnswerRe: Generics Problems Pin
Clifford Nelson7-Sep-12 7:23
Clifford Nelson7-Sep-12 7:23 
GeneralRe: Generics Problems Pin
Kevin Marois7-Sep-12 7:27
professionalKevin Marois7-Sep-12 7:27 
AnswerRe: Generics Problems Pin
Clifford Nelson7-Sep-12 7:42
Clifford Nelson7-Sep-12 7:42 
GeneralRe: Generics Problems Pin
Kevin Marois7-Sep-12 8:02
professionalKevin Marois7-Sep-12 8:02 
GeneralRe: Generics Problems Pin
Ennis Ray Lynch, Jr.7-Sep-12 8:51
Ennis Ray Lynch, Jr.7-Sep-12 8:51 
GeneralRe: Generics Problems Pin
Kevin Marois7-Sep-12 8:55
professionalKevin Marois7-Sep-12 8:55 
GeneralRe: Generics Problems Pin
Ennis Ray Lynch, Jr.7-Sep-12 9:05
Ennis Ray Lynch, Jr.7-Sep-12 9:05 
GeneralRe: Generics Problems Pin
Kevin Marois7-Sep-12 9:09
professionalKevin Marois7-Sep-12 9:09 
GeneralRe: Generics Problems Pin
Ennis Ray Lynch, Jr.7-Sep-12 9:21
Ennis Ray Lynch, Jr.7-Sep-12 9:21 
GeneralRe: Generics Problems Pin
Kevin Marois7-Sep-12 10:43
professionalKevin Marois7-Sep-12 10:43 
AnswerRe: Generics Problems Pin
Clifford Nelson7-Sep-12 9:31
Clifford Nelson7-Sep-12 9:31 
AnswerRe: Generics Problems Pin
Clifford Nelson7-Sep-12 9:09
Clifford Nelson7-Sep-12 9:09 
AnswerRe: Generics Problems Pin
PIEBALDconsult7-Sep-12 9:12
mvePIEBALDconsult7-Sep-12 9:12 
AnswerRe: Generics Problems Pin
Eddy Vluggen7-Sep-12 9:46
professionalEddy Vluggen7-Sep-12 9:46 
GeneralRe: Generics Problems Pin
Kevin Marois7-Sep-12 10:44
professionalKevin Marois7-Sep-12 10:44 
GeneralRe: Generics Problems Pin
Eddy Vluggen7-Sep-12 10:54
professionalEddy Vluggen7-Sep-12 10:54 
GeneralRe: Generics Problems Pin
Kevin Marois7-Sep-12 10:56
professionalKevin Marois7-Sep-12 10:56 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.