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

.NET (Core and Framework)

 
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 
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 
I got it, I got it, I got it.........Again! I found an elegant solution I think. A light bulb is starting shine!!!! Tell what you think about this solution. THis will allow me to use a static function. WOuld it be better to use an instance virtual function and have each derrived instance call the base.function instead?:

namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
B objB = new B();
List<iclass> oBList = new List<iclass>();
List oList = A.GetList();
}
}

public interface iClass
{
string Full_Name
{
get;
set;
}
string Short_Name
{
get;
set;
}
}


public class A : iClass
{
public A()
{
}
private string _PhoneA = "";
private string _Full_Name = "";
private string _Short_Name = "";
public string PhoneA
{
get { return _PhoneA; }
set { _PhoneA = value; }
}

public static List<t> GetList<t>() where T : iClass, new()
{
T obj = new T();
List<t> result = new List<t>();
obj.Full_Name = "Susan";
obj.Short_Name = "Su";

if (typeof(T) == typeof(A))
{

(obj as A).PhoneA = "444-4444";
result.Add(obj);
}
else if (typeof(T) == typeof(B))
{
(obj as B).SSN = "123-12-1111";
result.Add(obj);
}
return result;

}


public string Full_Name
{
get { return _Full_Name; }
set { _Full_Name = value; }
}
public string Short_Name
{
get { return _Short_Name; }
set { _Short_Name = value; }
}

}


public class B : A, iClass
{
private string _SSN = "";
public string SSN
{
get { return _SSN; }
set { _SSN = value; }
}
}


}

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 
GeneralRe: Getting a the real object from it's handle Pin
Shyam K Pananghat25-Jun-07 23:18
Shyam K Pananghat25-Jun-07 23:18 
QuestionDefault Fonts and Chinese Pin
nde_plume23-Jun-07 15:48
nde_plume23-Jun-07 15:48 
QuestionExecuting function on GUI-thread Pin
invictus323-Jun-07 8:48
invictus323-Jun-07 8:48 
AnswerRe: Executing function on GUI-thread Pin
Luc Pattyn23-Jun-07 9:04
sitebuilderLuc Pattyn23-Jun-07 9:04 

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.