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

C#

 
SuggestionRe: Select element from a List<> Pin
Richard Deeming7-Apr-15 2:21
mveRichard Deeming7-Apr-15 2:21 
GeneralRe: Select element from a List<> Pin
DPaul19947-Apr-15 6:43
DPaul19947-Apr-15 6:43 
Questionneed to order a file in stream read and write c# Pin
Member 115700984-Apr-15 7:31
Member 115700984-Apr-15 7:31 
AnswerRe: need to order a file in stream read and write c# Pin
PIEBALDconsult4-Apr-15 8:03
mvePIEBALDconsult4-Apr-15 8:03 
GeneralRe: need to order a file in stream read and write c# Pin
Member 115700984-Apr-15 8:26
Member 115700984-Apr-15 8:26 
QuestionC# class constructor best practice ? Pin
BillWoodruff4-Apr-15 5:05
professionalBillWoodruff4-Apr-15 5:05 
GeneralRe: C# class constructor best practice ? Pin
PIEBALDconsult4-Apr-15 5:52
mvePIEBALDconsult4-Apr-15 5:52 
GeneralRe: C# class constructor best practice ? Pin
BillWoodruff4-Apr-15 8:21
professionalBillWoodruff4-Apr-15 8:21 
Hi, I appreciate your comments.

For the sake of focusing on what I think is the key issue ... handling the need to have a constructor with a variable number of parameters some of which may be Action or Func ... which are used dynamically in the ctor ... the code I showed here is deliberately as terse and simple as possible.

In the real-world code I am working with (complex, involving Types other than int) the constructors in the library I am creating do need to trigger the construction of lists ... it's a key part of the class' functionality to provide the lists.

It's a personal preference of mine to avoid using 'params unless required, since I feel the use of named variables always contributes to code maintainability; but, of course, you're right in that they are sometimes absolutely necessary because you are dealing with an unpredictably variable number of inputs at run-time. So, I do use them; in fact, I use them in the current library I'm working on.

Your code example is interesting: I don't see you passing the 'i for-loop indexer to the Delegate, which seems strange. The use of 'Delegate there would require you to define a prototype for the Delegate Type like: public delegate T IntDelegate(); to use in the 'ctor.

On the other hand using a Func<T> would require no extra declaration, and, since Func is a Delegate, would be entirely equivalent.

cheers, Bill
«To kill an error's as good a service, sometimes better than, establishing new truth or fact.» Charles Darwin in "Prospero's Precepts"

GeneralRe: C# class constructor best practice ? Pin
PIEBALDconsult4-Apr-15 8:27
mvePIEBALDconsult4-Apr-15 8:27 
AnswerRe: C# class constructor best practice ? Pin
Eddy Vluggen4-Apr-15 6:47
professionalEddy Vluggen4-Apr-15 6:47 
GeneralRe: C# class constructor best practice ? Pin
BillWoodruff4-Apr-15 8:28
professionalBillWoodruff4-Apr-15 8:28 
GeneralRe: C# class constructor best practice ? Pin
PIEBALDconsult4-Apr-15 8:50
mvePIEBALDconsult4-Apr-15 8:50 
GeneralRe: C# class constructor best practice ? Pin
Eddy Vluggen4-Apr-15 11:13
professionalEddy Vluggen4-Apr-15 11:13 
GeneralRe: C# class constructor best practice ? Pin
BillWoodruff4-Apr-15 21:42
professionalBillWoodruff4-Apr-15 21:42 
GeneralRe: C# class constructor best practice ? Pin
Eddy Vluggen5-Apr-15 13:13
professionalEddy Vluggen5-Apr-15 13:13 
QuestionIs there any solution to design report instead of Crystal? Pin
aahamdan4-Apr-15 4:14
aahamdan4-Apr-15 4:14 
AnswerRe: Is there any solution to design report instead of Crystal? Pin
OriginalGriff4-Apr-15 4:44
mveOriginalGriff4-Apr-15 4:44 
AnswerRe: Is there any solution to design report instead of Crystal? Pin
tecnova14-Apr-15 4:58
professionaltecnova14-Apr-15 4:58 
GeneralRe: Is there any solution to design report instead of Crystal? Pin
aahamdan4-Apr-15 10:14
aahamdan4-Apr-15 10:14 
GeneralRe: Is there any solution to design report instead of Crystal? Pin
tecnova18-Apr-15 14:54
professionaltecnova18-Apr-15 14:54 
AnswerRe: Is there any solution to design report instead of Crystal? Pin
Eddy Vluggen4-Apr-15 6:50
professionalEddy Vluggen4-Apr-15 6:50 
GeneralRe: Is there any solution to design report instead of Crystal? Pin
Mycroft Holmes5-Apr-15 14:35
professionalMycroft Holmes5-Apr-15 14:35 
GeneralRe: Is there any solution to design report instead of Crystal? Pin
Eddy Vluggen6-Apr-15 0:33
professionalEddy Vluggen6-Apr-15 0:33 
QuestionBest way to Sync data Pin
Jassim Rahma3-Apr-15 11:55
Jassim Rahma3-Apr-15 11:55 
AnswerRe: Best way to Sync data Pin
Afzaal Ahmad Zeeshan3-Apr-15 16:13
professionalAfzaal Ahmad Zeeshan3-Apr-15 16:13 

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.