Default value

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

    Default value

    Hello,

    I am creating a class where I have various properties.
    I was able to set default values for most properties which have common
    types.

    However, I am 3 properties which I don't know how to create the default
    value:

    1. Mail.Attachment Collection
    I want to make it empty. But I am not sure I can do this.

    Private _AttachmentColl ection As Mail.Attachment Collection
    <DefaultValue(" ")_
    Public Property AttachmentColle ction() As Mail.Attachment Collection
    ...

    2. Mail.MailAddres sCollection
    I want to create the default collection with only one MailAddress.
    The one which is available in my Web.Config file under:
    <system.net>
    <mailSettings >
    <smtp
    deliveryMethod = "network"
    from = "atelier@jaquel ineroxoatelier" >
    ...

    Private _ToCollection As Mail.MailAddres sCollection
    <DefaultValue(" ")_
    Public Property ToCollection() As Mail.MailAddres sCollection
    ...

    3. Mail.MailAddres sCollection
    I want this email colection to be empty. Similar to one. It is just
    a different collection type.

    Private _BccCollection As Mail.MailAddres sCollection
    <DefaultValue(" ")_
    Public Property BccCollection() As Mail.MailAddres sCollection

    4. Mail.MailAddres s
    I want to create this MailAddress with the datain my Web.Config.
    Similar to 2. It is just a MailAddress instead of a Collection.

    ' From
    Private _From As Mail.MailAddres s
    Public Property From() As Mail.MailAddres s
    ...

    Could someone help me out with this?

    Thanks,
    Miguel

  • Gaurav Vaish \(www.EdujiniOnline.com\)

    #2
    Re: Default value

    1. Mail.Attachment Collection
    I want to make it empty. But I am not sure I can do this.
    Mail.Attachment Collection.Clea r()
    2. Mail.MailAddres sCollection
    I want to create the default collection with only one MailAddress.
    Ask SmtpSection to give the appropriate details.
    Clear the collection and then add one entry.
    3. Mail.MailAddres sCollection
    I want this email colection to be empty. Similar to one. It is just
    a different collection type.
    Collections are always 'Clear'-able.
    4. Mail.MailAddres s
    Again, talk to SmtpSection


    SmtpSection is in namespace System.Net.Conf iguration in System.dll

    An example:

    SmtpSection smtpSettings = (SmtpSection)
    ConfigurationMa nager.GetSectio n("system.net/mailSettings/smtp",
    typeof(SmtpSect ion));

    string from = smtpSettings.Fr om;


    --
    Happy Hacking,
    Gaurav Vaish | www.mastergaurav.com


    -----------------------------------------



    Comment

    Working...