stop creation

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Frank

    stop creation

    Hello,
    I have as class and when I get wrong data when creating the object (in the
    'new' routine) I want to break off the creation of the classObject, so it
    results in 'nothing' to the creator . How can I do that?
    Thanx
    Frank


  • Armin Zingler

    #2
    Re: stop creation

    "Frank" <frank@frank.co m> schrieb[color=blue]
    > Hello,
    > I have as class and when I get wrong data when creating the object
    > (in the 'new' routine) I want to break off the creation of the
    > classObject, so it results in 'nothing' to the creator . How can I do
    > that? Thanx
    > Frank[/color]

    Catch the error in the procedure creating the object.
    Optionally/Additionally add a shared function to the class creating the
    object and returning Nothing if an exception was thrown.


    --
    Armin

    How to quote and why:



    Comment

    • Herfried K. Wagner [MVP]

      #3
      Re: stop creation

      * "Frank" <frank@frank.co m> scripsit:[color=blue]
      > I have as class and when I get wrong data when creating the object (in the
      > 'new' routine) I want to break off the creation of the classObject, so it
      > results in 'nothing' to the creator . How can I do that?[/color]

      Throw an exception in the ctor. Alternatively, you can provide a shared
      method that returns an object of the class' type or 'Nothing' if
      creation fails.

      --
      Herfried K. Wagner [MVP]
      <URL:http://dotnet.mvps.org/>

      Comment

      • Armin Zingler

        #4
        Re: stop creation

        "Herfried K. Wagner [MVP]" <hirf-spam-me-here@gmx.at> schrieb[color=blue]
        > * "Frank" <frank@frank.co m> scripsit:[color=green]
        > > I have as class and when I get wrong data when creating the object
        > > (in the 'new' routine) I want to break off the creation of the
        > > classObject, so it results in 'nothing' to the creator . How can I
        > > do that?[/color]
        >
        > Throw an exception in the ctor. Alternatively, you can provide a
        > shared method that returns an object of the class' type or 'Nothing'
        > if creation fails.[/color]

        Good suggestion! ;-)


        --
        Armin

        Comment

        Working...