Visualizzazione dei risultati da 1 a 2 su 2
  1. #1

    Property set e value nothing

    Vorrei definire una proprietà in modo che, laddove non le venga attribuito un valore dal programmatore, acquisisca un valore di default. Io avevo pensato di impostare la cosa in questa maniera:

    codice:
    Public writeonly Property MyHashKey As String
      Set
        if value is nothing then
          _myhashkey = "User"
        else
          _myhashkey = value
        end if
      End Set
    End Property
    In questo modo se scrivo MiaClasse.MyHashKey = "Pippo" la proprietà avrà valore "Pippo". Se invece non preciso nulla la proprietà avrà valore "User".

    Solo che evidentemente "is nothing" non è corretto perchè se do un valore alla proprietà tutto bene, ma se non do alcun valore la proprietà rimane nothing anzichè User.

    Come posso fare?

    Ciao e grazie
    www.radiana.it - Spartiti musicali e Mp3

  2. #2
    Utente di HTML.it L'avatar di biste
    Registrato dal
    Apr 2001
    Messaggi
    877
    codice:
    Protected _myhashkey As String = "User"
    Public writeonly Property MyHashKey As String
      Set
        if Not value is nothing then
          _myhashkey = value
        end if
      End Set
    End Property
    HTH
    UGIdotNET
    Microsoft .NET MCAD
    C++, C#, VB6, VB.NET, ASP, ASP.NET
    SQL Server 2000

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2024 vBulletin Solutions, Inc. All rights reserved.