Click here to Skip to main content
15,914,163 members
Home / Discussions / C#
   

C#

 
GeneralRe: Using A Retrieved Type Pin
DaveyM6924-Jan-09 2:48
professionalDaveyM6924-Jan-09 2:48 
GeneralRe: Using A Retrieved Type Pin
#realJSOP24-Jan-09 3:10
professional#realJSOP24-Jan-09 3:10 
GeneralRe: Using A Retrieved Type Pin
#realJSOP24-Jan-09 3:13
professional#realJSOP24-Jan-09 3:13 
AnswerRe: Using A Retrieved Type Pin
DaveyM6925-Jan-09 0:42
professionalDaveyM6925-Jan-09 0:42 
GeneralRe: Using A Retrieved Type Pin
#realJSOP26-Jan-09 2:56
professional#realJSOP26-Jan-09 2:56 
GeneralRe: Using A Retrieved Type Pin
DaveyM6926-Jan-09 3:50
professionalDaveyM6926-Jan-09 3:50 
GeneralRe: Using A Retrieved Type Pin
#realJSOP26-Jan-09 5:28
professional#realJSOP26-Jan-09 5:28 
GeneralRe: Using A Retrieved Type Pin
DaveyM6926-Jan-09 10:02
professionalDaveyM6926-Jan-09 10:02 
It doesn't help as such as in the example I gave, it forces Employee1 to implement Property2, but in its implementation it returns simply "Not Applicable". As I said previously, it should really throw a NotImplementedException so:
get { throw new NotImplementedException("Not Applicable"); }
and
try
{
    subItem.Text = employee.Property2;
}
catch (NotImplementedException ex)
{
    subItem.Text = ex.Message;
}
The advantage is it gives you a common minimum implementation for all possible employee classes so you can treat all employee classes as equal for list building etc. Very similar to having an abstract base class but without providing any base implementation.

I suppose the interface should only have Property1, but then it wouldn't be any use in your situation.

Another alternative option I suppose is to provide a ToEmployee2() method in Employee1, but that seems wrong as you're coupling the two classes together and Employee1 is an Employee1, NOT an Employee2. That's why I prefer to use an interface rather than deriving from another similar class, unless it's definately a 'extended' version (EmployeeEx) of the base, in which case I wouldn't be showing the extended properties in the ListView as it's a list of Employee properties, not EmployeeEx.

Dave
BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)
Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia)

GeneralRe: Using A Retrieved Type Pin
DaveyM6926-Jan-09 4:11
professionalDaveyM6926-Jan-09 4:11 
AnswerRe: Using A Retrieved Type Pin
DaveyM6926-Jan-09 11:26
professionalDaveyM6926-Jan-09 11:26 
Questionİf one array Label Enabled=false Pin
ammoti24-Jan-09 1:51
ammoti24-Jan-09 1:51 
GeneralRe: İf one array Label Enabled=false Pin
Guffa24-Jan-09 9:12
Guffa24-Jan-09 9:12 
GeneralRe: İf one array Label Enabled=false Pin
ammoti24-Jan-09 10:52
ammoti24-Jan-09 10:52 
AnswerRe: İf one array Label Enabled=false Pin
Guffa24-Jan-09 12:19
Guffa24-Jan-09 12:19 
GeneralRe: İf one array Label Enabled=false Pin
ammoti24-Jan-09 12:51
ammoti24-Jan-09 12:51 
GeneralRe: İf one array Label Enabled=false Pin
Guffa24-Jan-09 14:46
Guffa24-Jan-09 14:46 
Questionretrieving songs from database using voice input.. Pin
a4abhi24-Jan-09 1:39
a4abhi24-Jan-09 1:39 
AnswerRe: retrieving songs from database using voice input.. Pin
WebMaster26-Jan-09 3:25
WebMaster26-Jan-09 3:25 
GeneralRe: retrieving songs from database using voice input.. Pin
a4abhi11-Feb-09 7:30
a4abhi11-Feb-09 7:30 
Questionstring to array Pin
lawrenceinba24-Jan-09 1:12
lawrenceinba24-Jan-09 1:12 
AnswerRe: string to array Pin
User 665824-Jan-09 1:20
User 665824-Jan-09 1:20 
AnswerRe: string to array Pin
DaveyM6924-Jan-09 1:21
professionalDaveyM6924-Jan-09 1:21 
GeneralRe: string to array Pin
lawrenceinba24-Jan-09 1:55
lawrenceinba24-Jan-09 1:55 
AnswerRe: string to array [modified] Pin
Luc Pattyn24-Jan-09 2:09
sitebuilderLuc Pattyn24-Jan-09 2:09 
GeneralRe: string to array Pin
User 665824-Jan-09 2:17
User 665824-Jan-09 2:17 

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.