Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Newbie question

Status
Not open for further replies.

Laeg

Programmer
Nov 29, 2004
95
IE
Coming from a vb background here, what is the variable scope in c#. For example I want to declare a variable in my class and have it available to the methods within that class.

Code:
public partial class _Default : System.Web.UI.Page
{

    public string sTest = "";

    public static bool MyFunc() {

        response.write sTest;
 
    }
}

How can I make sTest available to MyFunc? Is there a more C# orientated way of doing this?
 
Make sTest static or remove static from MyFunc
 
Just so it is clear - static is the equivelant of "Shared" in VB.Net.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top