how to init values in structure?

Discussion in 'ASP .Net' started by Peter Rilling, Aug 2, 2005.

  1. Okay, I have a structure where I want to initialize the fields to some
    special value, but I cannot initialize them directly (e.g. private bool
    myBool = false) and I cannot create a defauld constructor.

    Is there anyway I can do this? I know that I could make this a class rather
    then a structure, but I would like it to be a value type.
     
    Peter Rilling, Aug 2, 2005
    #1
    1. Advertising

  2. Peter Rilling

    Karl Seguin Guest

    No, though god knows you could have a constructor with a single parameter
    "bool initializeDefault" and just do a bunch of stuff in there

    public Coordinate(bool initializeDefault)
    {
    x = 3;
    y = 2;
    }

    I feel dirty though...

    Karl

    --
    MY ASP.Net tutorials
    http://www.openmymind.net/ - New and Improved (yes, the popup is annoying)
    http://www.openmymind.net/faq.aspx - unofficial newsgroup FAQ (more to
    come!)


    "Peter Rilling" <> wrote in message
    news:...
    > Okay, I have a structure where I want to initialize the fields to some
    > special value, but I cannot initialize them directly (e.g. private bool
    > myBool = false) and I cannot create a defauld constructor.
    >
    > Is there anyway I can do this? I know that I could make this a class
    > rather
    > then a structure, but I would like it to be a value type.
    >
    >
     
    Karl Seguin, Aug 2, 2005
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Tony Cheng
    Replies:
    1
    Views:
    8,285
    Juan T. Llibre
    Feb 24, 2006
  2. Stef

    howto init 2d structure to zero ?

    Stef, May 24, 2005, in forum: C Programming
    Replies:
    14
    Views:
    787
  3. Replies:
    1
    Views:
    684
    Jules
    Aug 18, 2005
  4. Jess
    Replies:
    4
    Views:
    462
  5. news.aon.at
    Replies:
    11
    Views:
    666
    Ian Collins
    Jan 29, 2011
Loading...

Share This Page