2

Do I need to make a new instance of the class and then reference that first?

For example:

PageExtension.SortWrapper listDoingSorting = New PageExtension.SortWrapper();
listDoingSorting = New List<SortWrapper>(); //creating list to do sorting
  • 1
    can you put your understanding through some sample code – Santanu Boral May 25 '17 at 4:24
  • That is what I have so far. I have seen other posts on here but still confused. I have the inner class part but I am not sure how to build a list of it. and thanks @adrian – Andrew Mayes May 25 '17 at 4:28
2

You would need to create an instance of the type List<PageExtension.SortWrapper>:

List<PageExtension.SortWrapper> wrappers = new List<PageExtension.SortWrapper();

You can also construct single instance elements and add them to the collection:

wrappers.add(new PageExtension.SortWrapper());

Or you can populate elements at run time:

List<PageExtension.SortWrapper> wrappers = new List<PageExtension.SortWrapper>
{
    new PageExtension.SortWrapper()
};

There are more syntactic options available to you, but that should give you the basic idea.

  • This worked great. I see that when I add an object to the list it has me reference the parent class as well Il add as the correct answer as soon as it lets me. Thanks. – Andrew Mayes May 25 '17 at 4:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.