Click here to Skip to main content
15,174,547 members
Home / Discussions / C#
   

C#

 
AnswerRe: mdiparent_clickevent dosnt work right Pin
Eddy Vluggen8-Sep-12 5:46
professionalEddy Vluggen8-Sep-12 5:46 
QuestionDisplay Live TV Pin
Jassim Rahma7-Sep-12 23:28
MemberJassim Rahma7-Sep-12 23:28 
AnswerRe: Display Live TV Pin
Eddy Vluggen8-Sep-12 5:41
professionalEddy Vluggen8-Sep-12 5:41 
QuestionHow to retrieve dell drac ip's via c sharp? Pin
turbosupramk37-Sep-12 11:28
Memberturbosupramk37-Sep-12 11:28 
QuestionGenerics Problems Pin
Kevin Marois7-Sep-12 8:11
professionalKevin Marois7-Sep-12 8:11 
AnswerRe: Generics Problems Pin
Clifford Nelson7-Sep-12 8:23
MemberClifford Nelson7-Sep-12 8:23 
GeneralRe: Generics Problems Pin
Kevin Marois7-Sep-12 8:27
professionalKevin Marois7-Sep-12 8:27 
AnswerRe: Generics Problems Pin
Clifford Nelson7-Sep-12 8:42
MemberClifford Nelson7-Sep-12 8:42 
OK
What you need to do is create and interface:

C#
public interface IEntity
{
    string SomeProperty { get; set; }
    string Caption { get; set; }
}


Then use this interface on the classes:
C#
public class Entity1 : IEntity
{
    public string SomeProperty { get; set; }
    public string Name { get; set; }
}
public class Entity2 : IEntity
{
    public string SomeProperty { get; set; }
    public string Caption { get; set; }
}


Then use is in the generic:

C#
public partial class Form1<T> : Form where T : IEntity, new()
{
    T entity;

    public Form1()
    {
        InitializeComponent();
        entity = new T();
    }
}

GeneralRe: Generics Problems Pin
Kevin Marois7-Sep-12 9:02
professionalKevin Marois7-Sep-12 9:02 
GeneralRe: Generics Problems Pin
Ennis Ray Lynch, Jr.7-Sep-12 9:51
MemberEnnis Ray Lynch, Jr.7-Sep-12 9:51 
GeneralRe: Generics Problems Pin
Kevin Marois7-Sep-12 9:55
professionalKevin Marois7-Sep-12 9:55 
GeneralRe: Generics Problems Pin
Ennis Ray Lynch, Jr.7-Sep-12 10:05
MemberEnnis Ray Lynch, Jr.7-Sep-12 10:05 
GeneralRe: Generics Problems Pin
Kevin Marois7-Sep-12 10:09
professionalKevin Marois7-Sep-12 10:09 
GeneralRe: Generics Problems Pin
Ennis Ray Lynch, Jr.7-Sep-12 10:21
MemberEnnis Ray Lynch, Jr.7-Sep-12 10:21 
GeneralRe: Generics Problems Pin
Kevin Marois7-Sep-12 11:43
professionalKevin Marois7-Sep-12 11:43 
AnswerRe: Generics Problems Pin
Clifford Nelson7-Sep-12 10:31
MemberClifford Nelson7-Sep-12 10:31 
AnswerRe: Generics Problems Pin
Clifford Nelson7-Sep-12 10:09
MemberClifford Nelson7-Sep-12 10:09 
AnswerRe: Generics Problems Pin
PIEBALDconsult7-Sep-12 10:12
professionalPIEBALDconsult7-Sep-12 10:12 
AnswerRe: Generics Problems Pin
Eddy Vluggen7-Sep-12 10:46
professionalEddy Vluggen7-Sep-12 10:46 
GeneralRe: Generics Problems Pin
Kevin Marois7-Sep-12 11:44
professionalKevin Marois7-Sep-12 11:44 
GeneralRe: Generics Problems Pin
Eddy Vluggen7-Sep-12 11:54
professionalEddy Vluggen7-Sep-12 11:54 
GeneralRe: Generics Problems Pin
Kevin Marois7-Sep-12 11:56
professionalKevin Marois7-Sep-12 11:56 
GeneralRe: Generics Problems Pin
Eddy Vluggen7-Sep-12 12:09
professionalEddy Vluggen7-Sep-12 12:09 
AnswerRe: Generics Problems Pin
jschell7-Sep-12 11:39
Memberjschell7-Sep-12 11:39 
GeneralRe: Generics Problems Pin
Kevin Marois7-Sep-12 11:41
professionalKevin Marois7-Sep-12 11:41 

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.