Click here to Skip to main content
16,007,610 members
Home / Discussions / .NET (Core and Framework)
   

.NET (Core and Framework)

 
GeneralRe: PleaseHelp Pin
Guffa24-Jul-06 1:41
Guffa24-Jul-06 1:41 
GeneralRe: PleaseHelp Pin
Nagaraju_Focus24-Jul-06 1:56
Nagaraju_Focus24-Jul-06 1:56 
AnswerRe: PleaseHelp Pin
Guffa25-Jul-06 7:54
Guffa25-Jul-06 7:54 
QuestionEnumerating all users Pin
FalkoD22-Jul-06 22:40
FalkoD22-Jul-06 22:40 
AnswerRe: Enumerating all users Pin
Net_DNA22-Jul-06 22:47
Net_DNA22-Jul-06 22:47 
GeneralRe: Enumerating all users Pin
FalkoD23-Jul-06 0:00
FalkoD23-Jul-06 0:00 
QuestionHow about a constructor that autodestructs? Pin
Giancarlo Trevisan22-Jul-06 18:42
Giancarlo Trevisan22-Jul-06 18:42 
AnswerRe: How about a constructor that autodestructs? Pin
Colin Angus Mackay23-Jul-06 0:17
Colin Angus Mackay23-Jul-06 0:17 
Because a constructor must always return a new instance of the object you might like to look at alternatives.

For example: Use the factory pattern. Specifically: use a factory method.

A factory method is one that creates an object but is not a constructor. You might create one like this:
public class MyObj
{
    // private constructor - only things within the class can call it.
    private MyObj(/* parameters go here */)
    {
        // Do initialisation here.
    }
 
    public static CreateMyObj(/* parameters go here */)
    {
        MyObj result = null;
       
        // Check the parameters here
 
        if (parametersAreOkay)
        {
            result = new MyObj(/* parameters go here */);
        }
        return result;
    }
 
    // Rest of class goes here
}

The rest of the code cannot access the constructor, and must use the CreateMyObj factory method to instantiate the object. The method may return null if the object cannot be created.

Does this help?


GeneralRe: How about a constructor that autodestructs? Pin
Giancarlo Trevisan23-Jul-06 19:08
Giancarlo Trevisan23-Jul-06 19:08 
GeneralRe: How about a constructor that autodestructs? Pin
Colin Angus Mackay23-Jul-06 19:42
Colin Angus Mackay23-Jul-06 19:42 
GeneralRe: How about a constructor that autodestructs? Pin
Giancarlo Trevisan23-Jul-06 20:07
Giancarlo Trevisan23-Jul-06 20:07 
GeneralRe: How about a constructor that autodestructs? Pin
Colin Angus Mackay23-Jul-06 20:15
Colin Angus Mackay23-Jul-06 20:15 
GeneralRe: How about a constructor that autodestructs? Pin
Giancarlo Trevisan23-Jul-06 20:22
Giancarlo Trevisan23-Jul-06 20:22 
GeneralRe: How about a constructor that autodestructs? Pin
Guffa23-Jul-06 22:44
Guffa23-Jul-06 22:44 
GeneralRe: How about a constructor that autodestructs? Pin
Giancarlo Trevisan24-Jul-06 2:05
Giancarlo Trevisan24-Jul-06 2:05 
GeneralRe: How about a constructor that autodestructs? [modified] Pin
Dave Kreskowiak24-Jul-06 2:38
mveDave Kreskowiak24-Jul-06 2:38 
GeneralRe: How about a constructor that autodestructs? [modified] Pin
Giancarlo Trevisan24-Jul-06 2:57
Giancarlo Trevisan24-Jul-06 2:57 
GeneralRe: How about a constructor that autodestructs? Pin
Dave Kreskowiak24-Jul-06 6:44
mveDave Kreskowiak24-Jul-06 6:44 
GeneralRe: How about a constructor that autodestructs? [modified] Pin
Giancarlo Trevisan24-Jul-06 19:06
Giancarlo Trevisan24-Jul-06 19:06 
GeneralRe: How about a constructor that autodestructs? Pin
Colin Angus Mackay24-Jul-06 2:38
Colin Angus Mackay24-Jul-06 2:38 
GeneralRe: How about a constructor that autodestructs? Pin
Giancarlo Trevisan24-Jul-06 3:02
Giancarlo Trevisan24-Jul-06 3:02 
QuestionMS Word - like interface in .NET Pin
ravinamballa22-Jul-06 13:39
ravinamballa22-Jul-06 13:39 
AnswerRe: MS Word - like interface in .NET Pin
Ed.Poore22-Jul-06 21:12
Ed.Poore22-Jul-06 21:12 
GeneralRe: MS Word - like interface in .NET Pin
ravinamballa23-Jul-06 1:23
ravinamballa23-Jul-06 1:23 
Questionwindows service and unmanaged dll Pin
simon_pl22-Jul-06 12:43
simon_pl22-Jul-06 12:43 

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.