Wrox Programmer Forums
Go Back   Wrox Programmer Forums > C# and C > C# 2005 > C# 2005
|
C# 2005 For discussion of Visual C# 2005.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the C# 2005 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old October 13th, 2007, 07:05 AM
Authorized User
 
Join Date: Dec 2005
Posts: 28
Thanks: 1
Thanked 0 Times in 0 Posts
Send a message via Yahoo to surendraparashar
Default Parameterized Property


Hi,

Anybody please tell me how to pass parameter in
c#. Is it possible as passible in vb, anybody
help me in details to create parameterized property.

Regards-
Surendra:)
Gurgaon
India

Surendra
__________________
Surendra Parashar
Gurgaon,
http://www.geocities.com/surendraparashar
 
Old October 13th, 2007, 08:37 AM
samjudson's Avatar
Friend of Wrox
 
Join Date: Aug 2007
Posts: 2,128
Thanks: 1
Thanked 189 Times in 188 Posts
Default

Is this what you mean? This define an index, default property to a class:

Code:
public class Class1 {
public int this[int index]
{
   get
      {   
          return index;   
      }
   set
      {   
      }
}
}
To use it you can then do this:

Code:
Class1 c = new Class1();
Console.WriteLine(c[i]);
If this isn't what you meant then please explain, perhaps giving an example of the VB code you want to reproduce.

/- Sam Judson : Wrox Technical Editor -/
 
Old October 17th, 2007, 06:39 AM
Authorized User
 
Join Date: Dec 2005
Posts: 28
Thanks: 1
Thanked 0 Times in 0 Posts
Send a message via Yahoo to surendraparashar
Default

Hi Sam,

I want to create property in c#, in which we can pass arguments like in c# method.

e.g.,

Response.QueryString["id"]

Here QueryString is a property of Response object,and we are passing string into it. I like to create
property like this. Please help with an example.

Surendra
 
Old October 17th, 2007, 07:31 AM
samjudson's Avatar
Friend of Wrox
 
Join Date: Aug 2007
Posts: 2,128
Thanks: 1
Thanked 189 Times in 188 Posts
Default

HttpRequest.QueryString is just defined as a property that returns a NameValueCollection object. Its then the NameValueCollection above that has the this[string] property defined that allows you to do QueryString["id"]. i.e. Response.QueryString["id"] is equivalent to:

Code:
NameValueCollection collection = Response.QueryString;
string id = collection["id"];

/- Sam Judson : Wrox Technical Editor -/
 
Old October 17th, 2007, 11:33 PM
Authorized User
 
Join Date: Dec 2005
Posts: 28
Thanks: 1
Thanked 0 Times in 0 Posts
Send a message via Yahoo to surendraparashar
Default

Thanks for your kind suggession

Surendra





Similar Threads
Thread Thread Starter Forum Replies Last Post
parameterized if-then not working hoqenishy XSLT 1 April 17th, 2008 01:25 PM
Parameterized Query asters VB.NET 2002/2003 Basics 5 July 9th, 2007 12:08 PM
Document() ... parameterized ? asearle XSLT 18 October 4th, 2006 02:46 AM
Parameterized SQLDataAdapter boyshey VB.NET 2002/2003 Basics 1 April 14th, 2006 07:08 AM
Parameterized OracleDataCommand narendra_patil BOOK: Beginning ASP.NET 1.0 0 April 21st, 2005 05:17 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.