1

I am struggling. Got properties that are of type ISet(of String) and I need to assign them with value.

.Add() 

throws empty link error since it is not instantiated, been trying to create an instance, assign value and pass with set(), but

Activator.CreateInstance(Type.GetType(MyClass.MyProperty)

throws empty link. Neither this solution Visual Basic: dynamically create objects using a string as the name works, I ve output the list and ISet is simply not there.
I've been trying to solve this for a while now.

1
  • 2
    The class which implements the property ought to be initializing the underlying object, not the consuming code. ISet is an interface, so you can use it to declare objects and cast to it, but you cannot create instances of them; they are simply a contract of what methods and properties a given type (class) will implement. Commented May 16, 2016 at 21:50

1 Answer 1

2

Interfaces don't fully define objects. They only define one part of an object, and therefore you don't have enough information from the ISet(Of String) interface on it's own to create an instance.

What you need to do is find a type that implements the interface, and create one of those... HashSet(Of String) and SortedSet(Of String) would both work.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.