Results 1 to 5 of 5

Thread: convert this property from VB to C#?

  1. #1

    Thread Starter
    l33t! MrPolite's Avatar
    Join Date
    Sep 2001
    Posts
    4,428

    Talking convert this property from VB to C#?

    is it possible in C# to have something like this?

    Public Property foo(ByVal a As Integer, ByVal b As Integer) As Integer
    Get

    End Get
    Set(ByVal Value As Integer)

    End Set
    End Property


    I can't figure out how to pass arguments to a property
    rate my posts if they help ya!
    Extract thumbnail without reading the whole image file: (C# - VB)
    Apply texture to bitmaps: (C# - VB)
    Extended console library: (VB)
    Save JPEG with a certain quality (image compression): (C# - VB )
    VB.NET to C# conversion tips!!

  2. #2
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    C# properties are parameterless . You can't do this .

  3. #3

    Thread Starter
    l33t! MrPolite's Avatar
    Join Date
    Sep 2001
    Posts
    4,428
    what sadness!!!
    I guess VB introduces bad programming habits
    rate my posts if they help ya!
    Extract thumbnail without reading the whole image file: (C# - VB)
    Apply texture to bitmaps: (C# - VB)
    Extended console library: (VB)
    Save JPEG with a certain quality (image compression): (C# - VB )
    VB.NET to C# conversion tips!!

  4. #4
    yay gay PT Exorcist's Avatar
    Join Date
    Apr 2002
    Location
    . . . my reason of shame
    Posts
    2,729
    hmm not at all.
    Properties in .NET are just methods(functions) that have a get_ / set_ as prefix.
    \m/\m/

  5. #5
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339
    I agree that sucks. Also you can't bind to a method but you can to a property. I think an indexer is the closest thing maybe:
    VB Code:
    1. public class fooTest
    2. {
    3.  
    4.     private int _foo;
    5.  
    6.     public int this[int a, int b]
    7.     {
    8.         get
    9.         {
    10.             return _foo;
    11.         }
    12.         set
    13.         {
    14.             _foo=value;
    15.         }
    16.     }
    17.  
    18. }
    19.  
    20. ////syntax
    21.     fooTest f=new fooTest();
    22.     MessageBox.Show(f[1,1].ToString());

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