Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Adding a property in a Web Service
Message
De
19/05/2003 15:12:34
 
 
À
19/05/2003 15:03:17
Information générale
Forum:
ASP.NET
Catégorie:
Web Services
Divers
Thread ID:
00790056
Message ID:
00790107
Vues:
20
It's because in .NET classes any code aside from declarations has to be inside of a function or a sub. So a class basically contains only declarations and function definitions, the code only executes inside of the functions.

Roman


>>What you're trying to do here can be done with global variables. In .NET Web Services you declare them at the class level (outside of any functions), you can initialize them in the constructor and then you can use them from any function. You would only need to expose them as properties if you needed to access them from other classes.
>
>So far, I have this:
>
>
>Public Class WebService
>    Inherits System.Web.Services.WebService
>
>    Private cUrl As String = "http://www.levelextreme.com"
>    Private cUser As String = ""
>
>    <WebMethod()> _
>    Public Function HelloWorld(ByVal tcString As String) As String
>        Return tcString + cUrl + cUser
>    End Function
>
>End Class
>
>
>What surprises me is that I was not able to do this:
>
>
>Public Class WebService
>    Inherits System.Web.Services.WebService
>
>    Private cUrl As String
>    Private cUser As String
>
>    cUrl="http://www.levelextreme.com"
>    cUser=""
>
>    <WebMethod()> _
>    Public Function HelloWorld(ByVal tcString As String) As String
>        Return tcString + cUrl + cUser
>    End Function
>
>End Class
>
>
>Do you know why?
Roman Rehak, MCSD, MCDBA, MCSA
Competitive Computing
354 Mountain View Drive
Colchester, VT 05446-5824
802-764-1729
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform