Advertisement

12.23.2003 at 02:16PM PST, ID: 20833699
[x]
Attachment Details

Left and Right string functions

Asked by knowlton in C# Programming Language

Tags: string, left, right, function

In C#, how do I perform a Left(  ) and Right(  ) string function on a string?

For example:

Right("This is a beautiful day",3)

would equal

"day"

~~~~

Left("This is a beautiful day",3)

would equal

"Thi"



What I want to do is:

1)  Assign a value to a string.
2)  Determine if the string ends with a particular substring.
3)  If so, truncate the string so the string equals the string minus the substring (on the end).
4)  Concatenate a new substring on the end of the main string.

Scenario 1
//Main string = "This is a beautiful day,Accounts"
//substring to delete equals ",Accounts"
//replacement substring equals ",12345"
//Truncated string now equals:  "This is a beautiful day"
//Append replacement substring
//Main string now equals "This is a beautiful day,12345"


Scenario 2
//Main string = "This is a beautiful day,Buddy"
//substring to delete equals ",Accounts"
//replacement substring equals ",12345"
//substring sought for not found so Main String still now equals:  "This is a beautiful day,Buddy"
//Do not Append replacement substring
//Main string still equals "This is a beautiful day,Buddy"

Start Free Trial
[+][-]12.23.2003 at 02:55PM PST, ID: 9994204

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]12.23.2003 at 02:59PM PST, ID: 9994215

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]12.23.2003 at 03:03PM PST, ID: 9994231

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]12.23.2003 at 03:05PM PST, ID: 9994236

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]12.23.2003 at 03:10PM PST, ID: 9994260

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]12.23.2003 at 03:12PM PST, ID: 9994271

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]12.23.2003 at 08:39PM PST, ID: 9995151

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]12.23.2003 at 10:14PM PST, ID: 9995373

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]12.24.2003 at 09:44AM PST, ID: 9997489

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]12.24.2003 at 09:46AM PST, ID: 9997506

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]12.24.2003 at 09:52AM PST, ID: 9997535

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]12.24.2003 at 09:54AM PST, ID: 9997541

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]12.24.2003 at 09:54AM PST, ID: 9997543

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]12.24.2003 at 09:57AM PST, ID: 9997557

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]12.24.2003 at 09:58AM PST, ID: 9997561

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]12.24.2003 at 09:59AM PST, ID: 9997564

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zone: C# Programming Language
Tags: string, left, right, function
Sign Up Now!
Solution Provided By: _TAD_
Participating Experts: 7
Solution Grade: A
 
 
[+][-]12.24.2003 at 10:11AM PST, ID: 9997604

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]12.24.2003 at 10:13AM PST, ID: 9997611

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]12.24.2003 at 10:15AM PST, ID: 9997626

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]12.24.2003 at 10:21AM PST, ID: 9997655

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]12.24.2003 at 10:23AM PST, ID: 9997674

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

Start your 7-day free trial to view this Assisted Solution or ask the Experts your question.

 
[+][-]12.24.2003 at 10:28AM PST, ID: 9997689

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]12.24.2003 at 10:30AM PST, ID: 9997694

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]12.24.2003 at 10:33AM PST, ID: 9997702

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]06.01.2005 at 04:19AM PDT, ID: 14120392

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]09.30.2005 at 12:04PM PDT, ID: 14995116

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]09.30.2005 at 12:11PM PDT, ID: 14995178

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]09.30.2005 at 03:44PM PDT, ID: 14996655

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]09.30.2005 at 07:45PM PDT, ID: 14997350

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]10.05.2005 at 07:20AM PDT, ID: 15022029

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32