Wrox Programmer Forums
|
BOOK: Beginning Visual C#
This is the forum to discuss the Wrox book Beginning Visual C#, Revised Edition of Beginning C# for .NET v1.0 by Karli Watson, David Espinosa, Zach Greenvoss, Jacob Hammer Pedersen, Christian Nagel, Jon D. Reid, Matthew Reynolds, Morgan Skinner, Eric White; ISBN: 9780764543821
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning Visual C# 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 February 19th, 2004, 12:17 AM
Registered User
 
Join Date: Feb 2004
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to rf5976
Default About Ch06Ex05

<center>
I don't understand the meaning of the following codes. Could anyone tell me? Thank you very much!
</center>

----------------------------------------------------------------
int commaPos = input.IndexOf(',');
            double param1 = Convert.ToDouble(input.Substring(0, commaPos));
            double param2 = Convert.ToDouble(input.Substring(commaPos + 1, input.Length - commaPos - 1));
----------------------------------------------------------------


 
Old February 19th, 2004, 03:49 AM
Authorized User
 
Join Date: Aug 2003
Posts: 26
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to Chris Beach Send a message via AIM to Chris Beach Send a message via MSN to Chris Beach Send a message via Yahoo to Chris Beach
Default

SubString is kinda like the old VB's mid function

So the 2nd line gets the letters from the start to commapos, which the first line sets to the position of the first comma.
The 3rd line gets the letters from commpos+1 to the end of the string, which is worked out by taking the full lenght of the string-your start position.

Hopefully that makes enough sense:) Too early for me

 
Old February 19th, 2004, 06:51 AM
Registered User
 
Join Date: Feb 2004
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to rf5976
Default

Thank you very much! According to your statement, I found the reason about why I can't understand.
I think I make a mistake.

 
Old November 19th, 2007, 11:06 AM
Registered User
 
Join Date: Mar 2006
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I'm also straggled with this code.thanks God I found answer from here.
Now I understand from ur explanation.
Thank u:)
(0,commaPos)means from start to that comma code.
(commaPos+1,input.Lenth-commaPos-1)means this is start from the end of that comma to the end of the code."+1"because give a space to comma,right?










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