CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4

Threaded View

  1. #1
    Join Date
    Mar 2007
    Location
    Argentina
    Posts
    579

    How to restrict data passed

    I are coding a generic class that works as red black balanced binary tree. I wanna post it here when finished.

    (Is a shame that .NET does not have it predefined, like the array class.)

    That data structure will store objects types, to be sure that the user can store his own objects.

    My class declare the user object this way:
    Code:
    Public Module Red_Black_Tree
    	Private Class Node
    		Public Data As Object 'Each Data to store in this tree
    ...
    But I need to force the user to use only Object witch implements the Icomparable interface.

    I have two questions:

    1-¿Is there a way to declare this line
    Code:
    Public Data As Object
    to restrict it only to objects with Icomparable interface (or another workaround).?

    2-When the new() subroutine is called, to create a new data, I can Try utilize the Icomparable interface, and if it does not have it, then trow an error (surely the same exception on the Try...End Try block of code), but I would like to have a specific way to check that it implements the Icomparable interface.
    Last edited by Marraco; April 10th, 2008 at 10:13 AM.

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