default property ?

  • Thread starter Thread starter Jon Paal
  • Start date Start date
J

Jon Paal

Compiler Error Message: BC30367: Class 'System.Web.HttpContext' cannot be indexed because it has no default property.


how do I create a "default property" ??
 
You don't create a default property of an existing class.

You probably want the "Items" property...without having shown us any code,
my guess is that you want to do:

Context.Items("BLAH")

Karl
 
A default property is a property which is invoked when you use an indexer
without specifying the name of the property that takes an indexer. For
example, most Collections have a default property which allows you to
specify an item in the Collection via the following terminology:

SomeCollection[0] (C#)
SomeCollection(0) (VB.Net)

I am not familiar with how this is declared in VB.Net, but to do so in C#,
you would create a default property something like the following:

public class foo
{
private StringCollection _Strings = new StringCollection();

public int this[int index]
{
get { return _Strings[index]; }
set { _String[index] = value; }
}
}

As you can see, the default property doesn't have to refer to the object
itself, but can be defined in any number of ways.

I would suspect that in your case, you possibly referenced:

....HttpContext

or possibly

....HttpContext["foo"]

or possibly within a Page or other class having a System.Web.HttpContext
member:

Context

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer

Presuming that God is "only an idea" -
Ideas exist.
Therefore, God exists.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Back
Top