I've inherited an existing 2.0 framework asp.net web application.

The function returns a value of Icollection, but it says ICollection is not defined. I can import System.Collections, but I still wonder how it worked for them if they didn't have this imported.

They are only using these imports:

Imports System.Data
Imports System.Data.OracleClient
Imports System.Web.Configuration

Should I just import the ICollection and be done with it?

Also, the function has created an objCollection and is returning that object. But the function itself indicates it is returning the ICollection interface.

Is there an issue here? Is that normal?


Starr DuskkASP.NET VB.NET DeveloperAsked:
Who is Participating?
Snarf0001Connect With a Mentor Commented:
I'm assuming this is related to the question you posted a few minutes after this on the 2005 - 2008 upgrade?
If so, I would take a guess that something was lost in the project file during conversion, they could have had System.Collections in the project-wide "Imported namespaces", might have been dropped during the upgrade.
You're probably fine adding either directly to the page or back into the project imports area.

As for the ICollection return, it's perfectly fine.  That's one of the primary functions of an interface, to allow multiple different types of objects to be returned, as long as they impliment the same interface.
In the block calling the function, you then don't need to worry about what exact type of object it is.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.