Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
BOOK: ASP.NET 2.0 Instant Results ISBN: 978-0-471-74951-6
This is the forum to discuss the Wrox book ASP.NET 2.0 Instant Results by Imar Spaanjaars, Paul Wilton, Shawn Livermore; ISBN: 9780471749516
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: ASP.NET 2.0 Instant Results ISBN: 978-0-471-74951-6 section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
 
 
Thread Tools Display Modes
  #1 (permalink)  
Old March 18th, 2009, 07:54 AM
Registered User
 
Join Date: Feb 2007
Location: , , .
Posts: 6
Thanks: 1
Thanked 0 Times in 0 Posts
Default Diary Events Chapter 1 Vb.net to C#

Hi

I am integrating an events diary into a project using C# and I am having trouble converting the following VB.net code to c# from chapter one of ASP.NET 2.0 instant results:

DefaultPublicReadOnlyProperty Item(ByVal index AsInteger) As DiaryEvent
Get
ReturnCType(List.Item(index), DiaryEvent)
EndGet
EndProperty

Using a converter I get this:
publicDiaryEvent Item
{
get { return (DiaryEvent)List.Item[index]; }
}

which I know is incorrect? can someone show me the correct method?

Thanks

.Netster
  #2 (permalink)  
Old March 18th, 2009, 03:17 PM
Imar's Avatar
Wrox Author
Points: 71,164, Level: 100
Points: 71,164, Level: 100 Points: 71,164, Level: 100 Points: 71,164, Level: 100
Activity: 100%
Activity: 100% Activity: 100% Activity: 100%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 16,960
Thanks: 79
Thanked 1,559 Times in 1,536 Posts
Default

Hi there,

I didn't write that chapter so I don't know what exactly the code is supposed to do, but it looks like you want an indexed property. In C#, you need to use the keyword this to do this (no pun intended):
Code:
 
public DiaryEvent this[int index] 
{
  get { return (DiaryEvent)List[index]; }
}
For more info, check out this MSDN link: http://msdn.microsoft.com/en-us/libr...8VS.71%29.aspx

Hope this helps,

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
The Following User Says Thank You to Imar For This Useful Post:
.Netster (March 20th, 2009)
 


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
ASP.NET Diary Organizer in Vista vgharris0 BOOK: ASP.NET 2.0 Instant Results ISBN: 978-0-471-74951-6 1 February 28th, 2008 01:20 PM
Online Diary - Profiles (Chapter 1) alineurope BOOK: ASP.NET 2.0 Instant Results ISBN: 978-0-471-74951-6 4 January 17th, 2007 06:05 PM
ASP.NET 1.1 with VB.NET 2003 chapter 1 subroger Wrox Book Feedback 2 November 11th, 2004 12:52 PM
Beg. ASP.Net eCommerce with VB.Net - Chapter 5 James Hendrix All Other Wrox Books 0 October 22nd, 2003 11:45 PM



All times are GMT -4. The time now is 06:57 AM.


Powered by vBulletin®
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.