Click here to Skip to main content
15,884,298 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi all , i have private int Webmethod in Webservice file and i want to call it from WebForm . How can i make this ?
I call like this and it doen't work .
C#
protected void Button_Click(object sender, EventArgs e)
       {
        int x = Namespace.WebService1.GetPriv(string a, string b)

       }

Error
' Namespace.WebService1.GetPriv(string , string)' is inaccessible due to its protection level .
Posted
Updated 11-Nov-15 20:57pm
v2

1 solution

No, you cannot.
You need to make the method public if you want to access in another project.

public
The type or member can be accessed by any other code in the same assembly or another assembly that references it.
private
The type or member can be accessed only by code in the same class or struct.

Access Modifiers[^]
Accessibility Levels[^]


-KR
 
Share this answer
 
Comments
Андрей Голубцов 12-Nov-15 4:00am    
Thanks , first link helps me )
Krunal Rohit 12-Nov-15 4:41am    
Glad I could help. :-)

-KR

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900