Click here to Skip to main content
15,888,351 members
Home / Discussions / C#
   

C#

 
GeneralRe: Specified cast is not valid. i can't understand error Pin
Member 1289974620-Dec-16 2:34
Member 1289974620-Dec-16 2:34 
GeneralRe: Specified cast is not valid. i can't understand error Pin
Ralf Meier20-Dec-16 2:38
mveRalf Meier20-Dec-16 2:38 
AnswerRe: Specified cast is not valid. i can't understand error Pin
Ralf Meier20-Dec-16 2:36
mveRalf Meier20-Dec-16 2:36 
GeneralRe: Specified cast is not valid. i can't understand error Pin
Member 1289974620-Dec-16 2:44
Member 1289974620-Dec-16 2:44 
AnswerRe: Specified cast is not valid. i can't understand error Pin
Richard Deeming20-Dec-16 2:45
mveRichard Deeming20-Dec-16 2:45 
AnswerRe: Specified cast is not valid. i can't understand error Pin
Nelson Costa Inácio21-Dec-16 5:54
Nelson Costa Inácio21-Dec-16 5:54 
QuestionIs there anything wrong with passing state via argument? Pin
TheOnlyRealTodd20-Dec-16 0:12
professionalTheOnlyRealTodd20-Dec-16 0:12 
AnswerRe: Is there anything wrong with passing state via argument? Pin
Afzaal Ahmad Zeeshan20-Dec-16 0:39
professionalAfzaal Ahmad Zeeshan20-Dec-16 0:39 
No, I don't think there is anything "wrong" with your code. But the way I see it (in option 2), it is clear that your constructor is not just a constructor but also a processor, it processes the operands and then puts the result in result field.

If you are going to do this, then write them like,
SomeObjectProcessorResult myObject = SomeObject.Process(someString,Processor_Option_1);
var res = myObject.result;
This will make much more sense in C#, it does not any longer depend on the states of SomeObject (it is static), but does the same — gets input, processes and then gives out output.
C#
public class SomeObject {
   public static SomeObjectProcessorResult Process(string someString, ProcessorType option) {
      // process and return
   }
}

public class SomeObjectProcessResult {
   public Type result; // for property, Result.
}
This is a near C# definition of types, while ignoring the states.

Then in your first option, it is clear that the function is an instance one and will depend on states of object.

TheOnlyRealTodd wrote:
Option 2 also uses class state member variables whereas 1 just passes it function-to-function as argument.
Not so, you can ignore and from an external view I can easily think of implementation where I just process those parameters and ignore them (not save them). On the other hand, I can save those parameters in option 1 as state values. Smile | :)

That is the case in OOP, there are side effects everywhere. If you do not want to use side effects. Consider using F#, that is a functional programming language — but does have OOP. Laugh | :laugh:
The sh*t I complain about
It's like there ain't a cloud in the sky and it's raining out - Eminem
~! Firewall !~

GeneralRe: Is there anything wrong with passing state via argument? Pin
TheOnlyRealTodd20-Dec-16 17:56
professionalTheOnlyRealTodd20-Dec-16 17:56 
Questioni get an error (non-invocable member-- can't be used like a method) any help? Pin
Member 1289974619-Dec-16 23:21
Member 1289974619-Dec-16 23:21 
AnswerRe: i get an error (non-invocable member-- can't be used like a method) any help? Pin
Afzaal Ahmad Zeeshan19-Dec-16 23:32
professionalAfzaal Ahmad Zeeshan19-Dec-16 23:32 
GeneralRe: i get an error (non-invocable member-- can't be used like a method) any help? Pin
Member 1289974619-Dec-16 23:42
Member 1289974619-Dec-16 23:42 
GeneralRe: i get an error (non-invocable member-- can't be used like a method) any help? Pin
Afzaal Ahmad Zeeshan19-Dec-16 23:45
professionalAfzaal Ahmad Zeeshan19-Dec-16 23:45 
GeneralRe: i get an error (non-invocable member-- can't be used like a method) any help? Pin
OriginalGriff19-Dec-16 23:55
mveOriginalGriff19-Dec-16 23:55 
GeneralRe: i get an error (non-invocable member-- can't be used like a method) any help? Pin
Afzaal Ahmad Zeeshan20-Dec-16 0:00
professionalAfzaal Ahmad Zeeshan20-Dec-16 0:00 
GeneralRe: i get an error (non-invocable member-- can't be used like a method) any help? Pin
Member 1289974620-Dec-16 2:01
Member 1289974620-Dec-16 2:01 
QuestionUnable to copy file "obj\x86\Debug\**** Pin
Rebyc Rebyc19-Dec-16 5:40
Rebyc Rebyc19-Dec-16 5:40 
AnswerRe: Unable to copy file "obj\x86\Debug\**** Pin
Richard Deeming19-Dec-16 5:57
mveRichard Deeming19-Dec-16 5:57 
AnswerRe: Unable to copy file "obj\x86\Debug\**** Pin
Afzaal Ahmad Zeeshan19-Dec-16 23:39
professionalAfzaal Ahmad Zeeshan19-Dec-16 23:39 
QuestionC# Textbox number and symbols Pin
Pavlex418-Dec-16 6:12
Pavlex418-Dec-16 6:12 
AnswerRe: C# Textbox number and symbols Pin
Pavlex418-Dec-16 6:52
Pavlex418-Dec-16 6:52 
GeneralRe: C# Textbox number and symbols Pin
Pete O'Hanlon18-Dec-16 9:55
mvePete O'Hanlon18-Dec-16 9:55 
AnswerRe: C# Textbox number and symbols Pin
Michael_Davies18-Dec-16 7:31
Michael_Davies18-Dec-16 7:31 
QuestionConfused Over EventListener, EventRaiser, CallBack Pin
Liagapi18-Dec-16 1:57
Liagapi18-Dec-16 1:57 
AnswerRe: Confused Over EventListener, EventRaiser, CallBack Pin
Richard MacCutchan18-Dec-16 5:32
mveRichard MacCutchan18-Dec-16 5:32 

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.