Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
What is RIGHT() equivalent in C#
Message
From
21/05/2010 16:58:39
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
General information
Forum:
ASP.NET
Category:
Other
Environment versions
Environment:
C# 3.0
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01465459
Message ID:
01465518
Views:
51
>I am getting the idea. Up until now, we had not worked too much with manipulation of strings. Strange that we could go 11 weeks in this C# class and not do very much in this arena. String manipulation is the bread and butter of all programming in my mind.
>
>By the way, many of my ancestors lived in east Texas, some of them coming befoe Texas was its own country. I believe that some of them may have been citizens of Spain, and then Mexico, before Texas won its independence. They came from other southern and eastern states. So, hmmm, do I put down that I am Hispanic on those job application forms? :)
>
>Here's what I've figured out with my substitution for RIGHT() in the below code:
>
>
>        private void calculateTotalCostsButton_Click(object sender, EventArgs e)
>        {
>            // Get the count of items selected by user, which is also the
>            // length of the following array.
>            int arrayLength = purchaseListBox.Items.Count;
>            string[] priceListItemsString = new string[arrayLength];
>            decimal priceListItemsDecimal = new decimal(arrayLength);
>
>            for (int i = 0; i < arrayLength; i++ )
>            {
>                // Pick up the Items from the purchaseListBox and put them into an array string.
>                priceListItemsString[i] = purchaseListBox.Items[i].ToString();
>                string oneItemString = purchaseListBox.Items[i].ToString();
>                //int lengthOfString = purchaseListBox.Items[i].ToString().Length;
>                int lengthOfString = oneItemString.Length;
>                int startPosition = oneItemString.IndexOf("$") + 1; // Go 1 position past $ sign.
>                // Get the dollar amount string without the dollar sign.
>                priceListItemsString[i] =
>                    oneItemString.Substring(startPosition, lengthOfString - startPosition);
>            }
>
>            // You now have the array string containing the dollar amounts.
>            // Send the priceListItemsString array to BusinessClass as a parameter.
>
>        }
>
Looks like you were looking for something like this, not Right():
 {
 // Pick up the Items from the purchaseListBox and put them into an array string.
                priceListItemsString[i] = purchaseListBox.Items[i].ToString().Split('$').Last();
}
Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Previous
Reply
Map
View

Click here to load this message in the networking platform