Click here to Skip to main content
15,305,508 members
Home / Discussions / C#
   

C#

 
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
MemberJassim 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
Memberturbosupramk37-Sep-12 10:28 
QuestionGenerics Problems Pin
Kevin Marois7-Sep-12 7:11
professionalKevin Marois7-Sep-12 7:11 
AnswerRe: Generics Problems Pin
Clifford Nelson7-Sep-12 7:23
MemberClifford 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
MemberClifford Nelson7-Sep-12 7: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 8:02
professionalKevin Marois7-Sep-12 8:02 
GeneralRe: Generics Problems Pin
Ennis Ray Lynch, Jr.7-Sep-12 8:51
MemberEnnis 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
MemberEnnis 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
MemberEnnis 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
MemberClifford Nelson7-Sep-12 9:31 
AnswerRe: Generics Problems Pin
Clifford Nelson7-Sep-12 9:09
MemberClifford Nelson7-Sep-12 9:09 
AnswerRe: Generics Problems Pin
PIEBALDconsult7-Sep-12 9:12
professionalPIEBALDconsult7-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 
GeneralRe: Generics Problems Pin
Eddy Vluggen7-Sep-12 11:09
professionalEddy Vluggen7-Sep-12 11:09 
AnswerRe: Generics Problems Pin
jschell7-Sep-12 10:39
Memberjschell7-Sep-12 10:39 
GeneralRe: Generics Problems Pin
Kevin Marois7-Sep-12 10:41
professionalKevin Marois7-Sep-12 10: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.