CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Oct 2002
    Posts
    5

    How To Use A Property In C Sharp

    HELLO
    SIR WE ARE DOING WORD PROGRAMMING USING C SHARP, HAVE PROBLEM IN USING PROPERTIES , AFTER ADDING MSWORD.OLB .
    THERE ARE SOME INTERFACES AND CLASSES AS WELL , BUT HAVE PROBLEM IN USING PROPERTIES.
    /| )' _ _ _ /_| / _ _ _/
    / |//_) (// ( |/)//)(- ( /

  2. #2
    Join Date
    Jun 2002
    Location
    Philadelphia, PA
    Posts
    85
    Can you be a bit clearer? The basic way you define a property in C# is as follows.

    Code:
    public class MyClass
    {
      protected Int32 _x;
      public Int32 x
      {
        get { return _x; }
        set { _x = value; }
      }
    }
    You can then do:

    Code:
    public void MyMethod(void)
    {
      MyClass z = new MyClass();
      z.x = 15;
    }

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured