dcsimg
Results 1 to 3 of 3

Thread: [RESOLVED] A Class Public Property with one input parameter

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Aug 2016
    Posts
    177

    Resolved [RESOLVED] A Class Public Property with one input parameter

    I have a VB.NET code, but I don't know how to write in C#.

    Code:
    Public WriteOnly Property Borders(Edge As EdgeEnum) As LineStyleEnum
       Set(value As LineStyleEnum)
          If(Edge And EdgeEnum.Left) > CType(0S, EdgeEnum) Then
             //...
             Me.uc.SetBorder(j, i, EdgeEnum.Left, value)
          End If
    
      End Set
    End Property
    I got error. I don't know how to put input parameter Edge:
    Code:
    public LineStyleEnum Borders
    {
     set
      {
          if ((Edge & EdgeEnum.Left) > (EdgeEnum)0)
          {
             //...
             this.uc.SetBorder(j, i, EdgeEnum.Left, value);
          }
      }
    }

  2. #2
    Frenzied Member KGComputers's Avatar
    Join Date
    Dec 2005
    Location
    Cebu, PH
    Posts
    1,948

    Re: A Class Public Property with one input parameter

    VB.NET Supports parameterized properties, C# doesn't. The closest approach is to use Indexer.
    net-class-properties-setter-with-parameter

    is-there-a-way-to-pass-an-argument-to-a-setter
    Last edited by KGComputers; Nov 27th, 2016 at 12:38 PM.
    CodeBank: VB.NET & C#.NET | ASP.NET
    Programming: C# | VB.NET
    Blogs: Personal |Programming | GitHub
    ___________________________________________________________________________________

    Rating someone's post is a way of saying Thanks...

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Aug 2016
    Posts
    177

    Re: A Class Public Property with one input parameter

    Quote Originally Posted by KGComputers View Post
    VB.NET Supports parameterized properties, C# doesn't. The closest approach is to use Indexer.
    net-class-properties-setter-with-parameter

    is-there-a-way-to-pass-an-argument-to-a-setter
    Thanks.
    Two ways:
    1.
    public void SetBorders(EdgeEnum Edge,LineStyleEnum value)
    2. define Edge on Class Level:
    private EdgeEnum Edge;
    Last edited by DaveDavis; Nov 27th, 2016 at 08:01 PM.

Posting Permissions

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



Featured


Click Here to Expand Forum to Full Width