How to initialize a structure in C# should be piece of cake for experienced programmers

Last post 07-09-2009 6:06 PM by JeffreyABecker. 1 replies.

Sort Posts:

  • How to initialize a structure in C# should be piece of cake for experienced programmers

    07-09-2009, 8:48 AM
    • Member
      6 point Member
    • callvj1981
    • Member since 11-13-2008, 6:00 AM
    • Posts 45

      Hi, I am coding in C# I have a class. say class Flower and I have a structure say struct petals now this structure contains some reference types namely lists. I want to create a new Flower Object how will I initialize the list? Is this the correct way to do? Flower rose = new Flower(); Petals myPetals = new Petals(); rose.myPetals = myPetals.Initialize(); //Now myPetals does have an initialized struct variable but // is this how I am supposed to even to do this? class Flower { Petals myPetals; } struct Petals { public list WeatherInputs; public Petals Initialize { myObject = new List; return this; } }

     

     

    Will mark are resolved once you answer :)

     

    Just VJ
  • Re: How to initialize a structure in C# should be piece of cake for experienced programmers

    07-09-2009, 6:06 PM
    Answer
    • Star
      14,310 point Star
    • JeffreyABecker
    • Member since 10-04-2004, 4:27 AM
    • Philadelphia, PA
    • Posts 2,916

    I'm not sure why Petals is a structure here.  Theres nothing about Petals that makes me think it should have pass-by-value and copy-by-value semantics. 

Page 1 of 1 (2 items)