Hello
This code returns 0 instead of 9. I can't find my mistake.
Thanks
Valerie
oop.aspx.cs file
- namespace OopC
- {
- public partial class oop : System.Web.UI.Page
- {
- protected void Button2_Click(object sender, System.EventArgs e)
- {
- Encaps enc = new Encaps();
- int z = 3;
- enc.Field = z;
- z= enc.Result;
- Label2.Text = z.ToString();
- }
- }
oop.apsx file
- <%@ page language="C#" autoeventwireup="true" validaterequest="false" inherits="OopC.oop" CodeBehind="oop.aspx.cs" %>
- <asp:Button ID="Button2" runat="server" Text="encapsulation" OnClick="Button2_Click" />
- <asp:Label ID="Label2" runat="server" Text=""></asp:Label><br />
in App_Code map: there is a file which contains this:
- public class Encaps
- {
- private int _Field;
- private int MethodB()
- {
- return _Field * 3;
- }
- public int Field
- {
- get
- {
- return _Field;
- }
- set
- {
- _Field = value;
- }
- }
- public int Result
- {
- get
- {
- return MethodB();
- }
- }
- }