Click here to Skip to main content
15,887,175 members
Home / Discussions / C#
   

C#

 
AnswerRe: Casting ItemsControl.ItemsSource to Generic Collection Pin
#realJSOP9-Sep-10 7:29
mve#realJSOP9-Sep-10 7:29 
AnswerRe: Casting ItemsControl.ItemsSource to Generic Collection Pin
Ian Shlasko9-Sep-10 10:51
Ian Shlasko9-Sep-10 10:51 
GeneralRe: Casting ItemsControl.ItemsSource to Generic Collection Pin
Jammer9-Sep-10 23:53
Jammer9-Sep-10 23:53 
AnswerRe: Casting ItemsControl.ItemsSource to Generic Collection Pin
Paul Michalik10-Sep-10 9:30
Paul Michalik10-Sep-10 9:30 
Questionwhat is advantges of using interface reference instead of class refernce Pin
am 20098-Sep-10 23:11
am 20098-Sep-10 23:11 
AnswerRe: what is advantges of using interface reference instead of class refernce Pin
DaveyM698-Sep-10 23:14
professionalDaveyM698-Sep-10 23:14 
AnswerRe: what is advantges of using interface reference instead of class refernce Pin
OriginalGriff9-Sep-10 0:22
mveOriginalGriff9-Sep-10 0:22 
AnswerRe: what is advantges of using interface reference instead of class refernce [modified] Pin
Pete O'Hanlon9-Sep-10 1:44
mvePete O'Hanlon9-Sep-10 1:44 
In your example, there's very little advantage. Where the use of the interface comes into its own is when you want to perform a specific method, e.g. Dispose an object. Rather than having to use reflection to determine whether or not an object contains that method, you can use the interface to do the action. Consider the following snippet:
Data obj = new Data();
ICheck check = obj as ICheck;
if (check != null)
  check.Fun();
Now, if Data doesn't implement this interface, the code still compiles and behaves as you'd expect. This really comes into its own if you are using something like Inversion of Control where you'd use the interface to retrieve the object, e.g.:
ICheck obj = MyIocContainer.Resolve(/* some reference to the Data class);
obj.Fun();

I have CDO, it's OCD with the letters in the right order; just as they ruddy well should be

Forgive your enemies - it messes with their heads


My blog | My articles | MoXAML PowerToys | Onyx


modified on Saturday, September 11, 2010 8:14 AM

GeneralICheck Pin
Paul Michalik9-Sep-10 20:23
Paul Michalik9-Sep-10 20:23 
GeneralRe: ICheck Pin
Pete O'Hanlon11-Sep-10 2:16
mvePete O'Hanlon11-Sep-10 2:16 
AnswerRe: what is advantges of using interface reference instead of class refernce Pin
PIEBALDconsult9-Sep-10 4:03
mvePIEBALDconsult9-Sep-10 4:03 
AnswerRe: what is advantges of using interface reference instead of class refernce Pin
Pete O'Hanlon9-Sep-10 4:47
mvePete O'Hanlon9-Sep-10 4:47 
AnswerRe: what is advantges of using interface reference instead of class refernce Pin
Paul Michalik9-Sep-10 21:05
Paul Michalik9-Sep-10 21:05 
QuestionHow to pass ArrayList object back from a Thread Pin
largenqcd8-Sep-10 16:41
largenqcd8-Sep-10 16:41 
AnswerRe: How to pass ArrayList object back from a Thread Pin
Luc Pattyn8-Sep-10 16:56
sitebuilderLuc Pattyn8-Sep-10 16:56 
Questionconvert VB code to C# code [modified] Pin
krobinson9378-Sep-10 15:35
krobinson9378-Sep-10 15:35 
AnswerRe: convert VB code to C# code Pin
Luc Pattyn8-Sep-10 15:56
sitebuilderLuc Pattyn8-Sep-10 15:56 
AnswerRe: convert VB code to C# code Pin
J4amieC8-Sep-10 22:02
J4amieC8-Sep-10 22:02 
AnswerRe: convert VB code to C# code Pin
AspDotNetDev9-Sep-10 13:04
protectorAspDotNetDev9-Sep-10 13:04 
QuestionHiding/Showing panels Pin
Megidolaon8-Sep-10 12:46
Megidolaon8-Sep-10 12:46 
AnswerRe: Hiding/Showing panels Pin
Luc Pattyn8-Sep-10 14:05
sitebuilderLuc Pattyn8-Sep-10 14:05 
AnswerRe: Hiding/Showing panels Pin
Dave Kreskowiak8-Sep-10 18:08
mveDave Kreskowiak8-Sep-10 18:08 
AnswerRe: Hiding/Showing panels Pin
The Man from U.N.C.L.E.9-Sep-10 7:34
The Man from U.N.C.L.E.9-Sep-10 7:34 
AnswerRe: Hiding/Showing panels Pin
Megidolaon9-Sep-10 8:15
Megidolaon9-Sep-10 8:15 
GeneralRe: Hiding/Showing panels Pin
OriginalGriff9-Sep-10 8:51
mveOriginalGriff9-Sep-10 8:51 

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.