Click here to Skip to main content
15,910,277 members
Home / Discussions / C#
   

C#

 
AnswerRe: Pound sign in XML Pin
Ennis Ray Lynch, Jr.7-Nov-11 6:58
Ennis Ray Lynch, Jr.7-Nov-11 6:58 
QuestionError please help Pin
Arunkumar.Koloth6-Nov-11 22:08
Arunkumar.Koloth6-Nov-11 22:08 
AnswerRe: Error please help Pin
Bernhard Hiller6-Nov-11 22:34
Bernhard Hiller6-Nov-11 22:34 
GeneralRe: Error please help Pin
Arunkumar.Koloth6-Nov-11 23:25
Arunkumar.Koloth6-Nov-11 23:25 
GeneralRe: Error please help Pin
Richard MacCutchan7-Nov-11 4:03
mveRichard MacCutchan7-Nov-11 4:03 
QuestionShamos Pin
msafary6-Nov-11 21:54
msafary6-Nov-11 21:54 
AnswerRe: Shamos PinPopular
Richard MacCutchan6-Nov-11 22:46
mveRichard MacCutchan6-Nov-11 22:46 
Question"economics" of casting to an interface in a parameter declaration of a method ? Pin
BillWoodruff6-Nov-11 20:41
professionalBillWoodruff6-Nov-11 20:41 
0. I ask you to "cut me some slack" here for presenting a trivially bare-bones code example for the sake of brevity.

0.a. My real-world exploration of this topic is related to exploring various techniques for synchronization of objects and data across Classes and Forms, and evaluating them in the context of projects where there are a lot of objects that need to be synchronized, and WinForms current default binding techniques do not seem to meet my needs.

0.b. I am quite familiar with other techniques for object "injection," and use of exposure of objects ... to 'outside' objects ... by public properties that are set to instances of objects. Exploring casting to 'Interface' in the sense of using it as a "filter" to limit what is exposed to other objects, rather than a "contract for implementation," is a new walk in the dark ... for me (but, my guess is, probably not ... for you).

1. Assume you have a simple Interface, something like:
CSS
public interface TheInterface
{
    string iText { get; set; }
}
2. Assume you have a simple class that implements that Interface
public class SimpleClass : TheInterface
{
    public string iText { get; set; }
}
3. In SimpleClass there's a method call, where the SimpleClass instance itself is passed as a parameter to a public method in another class:
SomeOtherClass.SomeMethod(this, "some string");
4. And the method, SomeMethod, has a parameter signature like this:
public void SomeMethod(TheInterface iFace, string someText)
{ 
    // okay let's make it do something trivial
    iFace.iText = someText; 
}
5. So in this case you might say that the "casting" of SimpleForm to TheInterface is performed implicitly, rather than explicitly (yes, I am aware it could be cast explictly, and passed as Type TheInterface).

Comment: in the 'real-world' usage I have in mind there would be an internal collection, something like List<TheInterface> which would be enumerated, and changes made to synchronize whatever with the whatever in the 'calling object' cast to TheInterface.

So, my question is: what are the internal "costs" of using this type of conversion: trivial ?

Does this kind of technique emit what devotees of Java so love to refer to as a "bad smell" ?

What method signatures, if any, in this scenario, would you define in an interface ?

I appreciate any comments or guidance !

thanks, Bill
"Last year I went fishing with Salvador Dali. He was using a dotted
line. He caught every other fish." Steven Wright

AnswerRe: "economics" of casting to an interface in a parameter declaration of a method ? Pin
harold aptroot6-Nov-11 21:37
harold aptroot6-Nov-11 21:37 
AnswerRe: "economics" of casting to an interface in a parameter declaration of a method ? Pin
Luc Pattyn6-Nov-11 22:56
sitebuilderLuc Pattyn6-Nov-11 22:56 
AnswerRe: "economics" of casting to an interface in a parameter declaration of a method ? Pin
PIEBALDconsult7-Nov-11 1:49
mvePIEBALDconsult7-Nov-11 1:49 
AnswerRe: "economics" of casting to an interface in a parameter declaration of a method ? Pin
DaveyM697-Nov-11 11:11
professionalDaveyM697-Nov-11 11:11 
GeneralRe: "economics" of casting to an interface in a parameter declaration of a method ? Pin
BillWoodruff7-Nov-11 19:03
professionalBillWoodruff7-Nov-11 19:03 
GeneralRe: "economics" of casting to an interface in a parameter declaration of a method ? Pin
DaveyM697-Nov-11 21:36
professionalDaveyM697-Nov-11 21:36 
GeneralRe: "economics" of casting to an interface in a parameter declaration of a method ? Pin
Pete O'Hanlon7-Nov-11 23:19
mvePete O'Hanlon7-Nov-11 23:19 
GeneralRe: "economics" of casting to an interface in a parameter declaration of a method ? Pin
DaveyM698-Nov-11 6:45
professionalDaveyM698-Nov-11 6:45 
GeneralRe: "economics" of casting to an interface in a parameter declaration of a method ? Pin
BobJanova8-Nov-11 0:14
BobJanova8-Nov-11 0:14 
GeneralRe: "economics" of casting to an interface in a parameter declaration of a method ? Pin
DaveyM698-Nov-11 6:57
professionalDaveyM698-Nov-11 6:57 
AnswerNot so simple (Re: "economics" of casting to an interface in a parameter declaration of a method?) Pin
Sergey Alexandrovich Kryukov8-Nov-11 14:58
mvaSergey Alexandrovich Kryukov8-Nov-11 14:58 
QuestionOmar Gameel, Apriori Algorithm Please Help..!!! Pin
Member 78679836-Nov-11 11:29
Member 78679836-Nov-11 11:29 
GeneralRe: Omar Gameel, Apriori Algorithm Please Help..!!! Pin
harold aptroot6-Nov-11 11:41
harold aptroot6-Nov-11 11:41 
AnswerRe: Omar Gameel, Apriori Algorithm Please Help..!!! Pin
Dalek Dave6-Nov-11 12:54
professionalDalek Dave6-Nov-11 12:54 
Questionauto check DataGridViewCheckBoxColumn Pin
Danzy836-Nov-11 10:52
Danzy836-Nov-11 10:52 
AnswerRe: auto check DataGridViewCheckBoxColumn Pin
Dalek Dave6-Nov-11 12:57
professionalDalek Dave6-Nov-11 12:57 
AnswerRe: auto check DataGridViewCheckBoxColumn Pin
Dr.Walt Fair, PE6-Nov-11 16:59
professionalDr.Walt Fair, PE6-Nov-11 16:59 

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.