What is the scope of public variable in different methods of a same class in Console C# -
i have class named data used retrieve user's data class data { public string firstname; public string lastname; public void getdata() { firstname = "abc"; lastname = "xyz"; } public static xdocument getdatatoxml() { var objget = new data(); objget.getdata(); xdocument doc = new xdocument( new xelement("firstname ", objget.firstname), new xelement("lastname", objget.firstname)); return doc; } public void display() { string fdata = firstname; //i "firstname" value null why???? } } class program { static void main(string[] args) { var obj = new data(); obj.getdata(); obj.display(); console.readline(); } } why null value when call di...