Click here to Skip to main content
15,887,027 members
Home / Discussions / .NET (Core and Framework)
   

.NET (Core and Framework)

 
GeneralRe: How to build a IP LAN Scanner in .Net Pin
Carmine_XX8-Jul-07 4:41
Carmine_XX8-Jul-07 4:41 
GeneralRe: How to build a IP LAN Scanner in .Net Pin
Ilya Verbitskiy8-Jul-07 21:19
Ilya Verbitskiy8-Jul-07 21:19 
QuestionGenerics, Inheritance and frustration Pin
Santiago Perez25-Jun-07 2:38
Santiago Perez25-Jun-07 2:38 
AnswerRe: Generics, Inheritance and frustration Pin
Andy L 225-Jun-07 7:10
Andy L 225-Jun-07 7:10 
GeneralRe: Generics, Inheritance and frustration Pin
Santiago Perez25-Jun-07 8:32
Santiago Perez25-Jun-07 8:32 
GeneralRe: Generics, Inheritance and frustration Pin
Andy L 226-Jun-07 0:16
Andy L 226-Jun-07 0:16 
GeneralRe: Generics, Inheritance and frustration Pin
Santiago Perez26-Jun-07 16:41
Santiago Perez26-Jun-07 16:41 
GeneralRe: Generics, Inheritance and frustration Pin
Santiago Perez26-Jun-07 18:28
Santiago Perez26-Jun-07 18:28 
Ok, I apologize again. Just having a frustrating day. I think I follow what you were trying to explain. I've also watched the webcast from Juval Lowy. What I was trying to explain in my previous post is that I got my function (not a method) to return a generic list of an interface that all my classes implement. What I don't quite understand is how I use this list in the referencing call if I'm expecting a List of of a specific type that implements that interface. Basically it looks to me like I have to iterate throuh the list and cast each object to my desired type in order to get the intelisense etc. Are you saying that I should have my function call look like this based on my last example? If so this won't compile because I get the following error on each result.Add()


Error 1 The best overloaded method match for 'System.Collections.Generic.List<t>.Add(T)' has some invalid arguments C:\Projects\ConsoleApplication1\ConsoleApplication1\Program.cs 95 17 ConsoleApplication1
Error 2 Argument '1': cannot convert from 'ConsoleApplication1.A' to 'T' C:\Projects\ConsoleApplication1\ConsoleApplication1\Program.cs 95 28 ConsoleApplication1


public static List<t> GetList<t>() where T : A,iClass
{
List<t> result = new List<t>();
iClass oC = null;
if (typeof(T) == typeof(A))
{
oC = new A();
((A)oC).Full_Name = "A_Tom";
result.Add((A)oC);

oC = new A();
((A)oC).Full_Name = "A_Bill";
result.Add((A)oC);

oC = new A();
((A)oC).Full_Name = "A_Jack";
result.Add((A)oC);

}
else if (typeof(T) == typeof(B))
{
oC = new B();
((B)oC).Full_Name = "b_Tom";
result.Add((B)oC);

oC = new B();
((B)oC).Full_Name = "B_Bill";
result.Add((B)oC);

oC = new B();
((B)oC).Full_Name = "B_Jack";
result.Add((B)oC);
}
return result;
}
GeneralRe: Generics, Inheritance and frustration Pin
Santiago Perez26-Jun-07 20:19
Santiago Perez26-Jun-07 20:19 
GeneralRe: Generics, Inheritance and frustration Pin
Andy L 226-Jun-07 22:37
Andy L 226-Jun-07 22:37 
GeneralRe: Generics, Inheritance and frustration Pin
Santiago Perez27-Jun-07 5:05
Santiago Perez27-Jun-07 5:05 
GeneralRe: Generics, Inheritance and frustration Pin
Santiago Perez27-Jun-07 5:29
Santiago Perez27-Jun-07 5:29 
GeneralRe: Generics, Inheritance and frustration Pin
Santiago Perez27-Jun-07 5:45
Santiago Perez27-Jun-07 5:45 
GeneralRe: Generics, Inheritance and frustration Pin
Santiago Perez28-Jun-07 7:34
Santiago Perez28-Jun-07 7:34 
GeneralRe: Generics, Inheritance and frustration Pin
Andy L 229-Jun-07 5:33
Andy L 229-Jun-07 5:33 
QuestionXML 3 BulkLoad Error Pin
Panchal Hardik25-Jun-07 2:25
Panchal Hardik25-Jun-07 2:25 
AnswerRe: XML 3 BulkLoad Error Pin
Dave Kreskowiak25-Jun-07 4:04
mveDave Kreskowiak25-Jun-07 4:04 
Questioninstallation .net 2005 Pin
Sumanth Pereji25-Jun-07 2:19
Sumanth Pereji25-Jun-07 2:19 
AnswerRe: installation .net 2005 Pin
Dave Kreskowiak25-Jun-07 4:09
mveDave Kreskowiak25-Jun-07 4:09 
GeneralRe: installation .net 2005 Pin
Pete O'Hanlon25-Jun-07 5:13
mvePete O'Hanlon25-Jun-07 5:13 
GeneralRe: installation .net 2005 Pin
Dave Kreskowiak25-Jun-07 5:56
mveDave Kreskowiak25-Jun-07 5:56 
GeneralRe: installation .net 2005 Pin
Pete O'Hanlon25-Jun-07 8:32
mvePete O'Hanlon25-Jun-07 8:32 
GeneralRe: installation .net 2005 Pin
originSH25-Jun-07 23:03
originSH25-Jun-07 23:03 
QuestionGetting a the real object from it's handle Pin
Shyam K Pananghat24-Jun-07 20:24
Shyam K Pananghat24-Jun-07 20:24 
AnswerRe: Getting a the real object from it's handle Pin
Dave Kreskowiak25-Jun-07 4:07
mveDave Kreskowiak25-Jun-07 4:07 

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.