473,503 Members | 6,354 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

set & get methods for Collections

i have SqlParameterCollection and i want to reach it by SET and GET
methods...

public SqlParameterCollection Parameter this[string Parameter]
{
get
{
return Command.Parameters[Parameter];
}
set
{
Command.Parameters[Parameter] = value;
}
}

which is not right... but i want to do ???
Nov 16 '05 #1
4 1453
Hi,

You have to write like this:

public SqlParameterCollection this[string Parameter]
{
get
{
return Command.Parameters[Parameter];
}
set
{
Command.Parameters[Parameter] = value;
}
}

Sridhar!!

"Sadun Sevingen" wrote:
i have SqlParameterCollection and i want to reach it by SET and GET
methods...

public SqlParameterCollection Parameter this[string Parameter]
{
get
{
return Command.Parameters[Parameter];
}
set
{
Command.Parameters[Parameter] = value;
}
}

which is not right... but i want to do ???

Nov 16 '05 #2
but this give collection property to object... i want to access into an
collection in the object...

lets say... i have object A and it has C attribute as collection... i want
to declare get property G to access C

when i wrote

A.G[key]

also i could get A.C[key]

Nov 16 '05 #3
What type of object does the Command.Parameters[Parameter] call return -- a
SqlParameter, right? So, the indexer would look like:

public SqlParameter this[string Parameter]
{
get
{
return Command.Parameters[Parameter];
}
set
{
Command.Parameters[Parameter] = value;
}
}

Ken
"Sadun Sevingen" <b-saduns@ms> wrote in message
news:%2***************@TK2MSFTNGP10.phx.gbl...
i have SqlParameterCollection and i want to reach it by SET and GET
methods...

public SqlParameterCollection Parameter this[string Parameter]
{
get
{
return Command.Parameters[Parameter];
}
set
{
Command.Parameters[Parameter] = value;
}
}

which is not right... but i want to do ???

Nov 16 '05 #4
SP
"Sadun Sevingen" <b-saduns@ms> wrote in message
news:O%****************@tk2msftngp13.phx.gbl...
but this give collection property to object... i want to access into an
collection in the object...

lets say... i have object A and it has C attribute as collection... i want
to declare get property G to access C

when i wrote

A.G[key]

also i could get A.C[key]


In your A class you need a property to get to your collection first.

public SqlParameterCollection Parameters
{
get
{
return this.pararmeters
}
set
{
this.parameters = value;
}
}

Then the collection class has the indexer

class Parameters
{
// indexer
public SqlParameter Parameter this[string Parameter]
{
get
{
return Command.Parameters[Parameter];
}
set
{
Command.Parameters[Parameter] = value;
}
}
}

SP
Nov 16 '05 #5

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

Similar topics

5
1358
by: John | last post by:
Hi, In my years as a VB programmer, I have settled into this pattern of creating collections classes, with an AddNew() method. AddNew() validates the parameters, instantiates the object, adds...
4
5072
by: John C | last post by:
I'm new to C#, so just point me at the correct reference material if this question has been answered before. When creating a new class which implements the IDictionary interface, two versions of...
2
2859
by: Marc | last post by:
Given a class 'Invoice' with a property 'public IMyColl<IInvoiceLine> InvoiceLines' where 'IMyColl<T> : IList<T>' i would like to detect by reflection that 'InvoiceLines' is a...
2
1500
by: S | last post by:
Hi there, I'm building an application that makes heavy use of centralized static methods (and variables) and would just appreciate hearing someone grade my understanding of the concept. In...
6
8300
by: snazzy | last post by:
I have a problem where using innerHTML to rewrite a DIV or removeChild to kill a DIV that either of them, if excuted before the page is done loading will stop the page in its tracks. ...
4
8170
by: nhmark64 | last post by:
Hi, Does System.Collections.Generic.Queue not have a Synchronized method because it is already in effect synchronized, or is the Synchronized functionality missing from...
14
2560
by: Jerad Rose | last post by:
I'm relatively new to C# and polymorphism, so what I'm trying to accomplish may not be possible, or there may be a totally different approach that I should be taking. I have a base class...
3
2546
by: jupiter | last post by:
The Collections class is supposed to, among other things, return type safe collections from existing collections with static methods such as .checkedList(). My question is: What is so special...
0
2733
by: dixonjm | last post by:
Hi, I have a master page & various pages that will use this master page. Each content page will have a CSS & JS file which will be named the same as the content page. When I try to load the CSS...
0
7207
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7093
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
1
7012
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5598
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5023
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3180
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3171
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1522
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
748
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.