473,320 Members | 1,820 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Sending parameter to properties

A.M
Hi,

I have a property in my class like this:

public string CurrentDisplayName
{
get
{
...
return s;
}
set
{
Session[LLCConstants.SESSION_INDEX_DISPLAYNAME] = value;
}
}
Can I send parameter to get/set methods? I am trying to do something like
this:

CurrentDisplayName(HttpContext) = "something";
or
variable = CurrentDisplayName(HttpContext)

Is that possible?

Thanks,
Alan

Nov 16 '05 #1
3 1252
Alan,

The only way you can do this is through indexers, in which case, your
object is indexed. If you want to expose this through a property, then you
have to create an object with an indexer that you want, and then expose an
instance of that object through a property.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"A.M" <IH*******@sapm123.com> wrote in message
news:%2***************@TK2MSFTNGP11.phx.gbl...
Hi,

I have a property in my class like this:

public string CurrentDisplayName
{
get
{
...
return s;
}
set
{
Session[LLCConstants.SESSION_INDEX_DISPLAYNAME] = value;
}
}
Can I send parameter to get/set methods? I am trying to do something like
this:

CurrentDisplayName(HttpContext) = "something";
or
variable = CurrentDisplayName(HttpContext)

Is that possible?

Thanks,
Alan

Nov 16 '05 #2
Hi Alan,

"A.M" <IH*******@sapm123.com> wrote in message
news:%2***************@TK2MSFTNGP11.phx.gbl...
Hi,

I have a property in my class like this: <snip> Can I send parameter to get/set methods? I am trying to do something like
this:

CurrentDisplayName(HttpContext) = "something";
or
variable = CurrentDisplayName(HttpContext)

Is that possible?

Thanks,
Alan


The short answer is "No". The longer answer is you can make it *look*
like that's what you are doing, but it's somewhat more involved. The
Page.Session property you reference in your property is an example of how it
can be done. The session property itself does not accept parameters, but the
HttpSessionState class that the property returns defines an "indexer". So,
if CurrentDisplayName returns an object that defines an indexer, you can use
syntax like this:

CurrentDisplayName[...] = "something"; // where "..." is the value of
the parameter passed to the indexer
or
variable = CurrentDisplayName[...];

Regards,
Daniel
Nov 16 '05 #3
Hi Alan,

For indexer declaration, you may refer to the link below.
Indexer Declaration
http://msdn.microsoft.com/library/de...us/csref/html/
vclrfindexedpropertiespg.asp
Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.

Nov 16 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Anuradha | last post by:
Dear All How can i send mails using vb.net Thanx all
7
by: D. Patrick | last post by:
I need to duplicate the functionality of a java applet, and how it connects to a remote server. But, I don't have the protocol information or the java source code which was written years ago. ...
8
by: Frank Millman | last post by:
Hi all This is not strictly a Python question, but as the system to which relates is written in Python, hopefully it is not too off-topic. I have an accounting/business application, written in...
11
by: rote | last post by:
I'm getting the email address from an excel sheet. But i need to send the email to multiple people When printing the below i get a@a.com;b@b.com;; But i want a@a.com;b@b.com; i don't need...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.