| | |
right, mid and left functions in c#
Please support our C# advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Mar 2008
Posts: 63
Reputation:
Solved Threads: 0
i have a tag;
XXX32353.mv
i need to be able to change the mv to something else, and the number of characters to the left of the . is not always constant. therefore i need to cut from the right, as the .mv is always the same,
what is the c# equivalent of this?
ive looked into substrings but that seems to be from the left only?
XXX32353.mv
i need to be able to change the mv to something else, and the number of characters to the left of the . is not always constant. therefore i need to cut from the right, as the .mv is always the same,
what is the c# equivalent of this?
ive looked into substrings but that seems to be from the left only?
To cut from the right, you can take a substring of a smaller length:
C# Syntax (Toggle Plain Text)
string q = s.Substring(0, s.Length - 2) + somethingElse; // replace "mv" with something else
-Tommy (For Great Justice!) Gunn
Use something like this:
Perhaps you could make some methods from this and put them in a class of your own, if you like.
c# Syntax (Toggle Plain Text)
string testStr = "123XYZ"; string leftStr = testStr.Substring(0, 2); // gives "12" string midStr = testStr.Substring(2, 3); // gives "3XY" string rightStr = testStr.Substring(testStr.Length - 4, 4);// gives "3XYZ"
Today is a gift, that's why it is called "The Present".
Make love, no war. Cave ab homine unius libri.
Danny
Make love, no war. Cave ab homine unius libri.
Danny
![]() |
Similar Threads
- creating separator bar in vb6 for the column (Visual Basic 4 / 5 / 6)
- Delete From String array (VB.NET)
- Help Me With Sorting Algo (C)
- listview row details (VB.NET)
- passing linked lists through functions?? (C++)
- Find out the problem of my code. (Java)
- Plz tell me how to implement this? (C#)
- HangMan game help. (VB.NET)
- find out the error in my code (Java)
- re: Sorting Algorithms (C++)
Other Threads in the C# Forum
- Previous Thread: graphics issue
- Next Thread: Problem with Alt-Tab while clipping mouse on Windows Vista
| Thread Tools | Search this Thread |
.net access ado.net algorithm api array barchart bitmap box broadcast buttons c# check checkbox client color combobox control conversion csharp custom database datagrid datagridview dataset datetime degrees development draganddrop drawing encryption enum event excel file files form format forms function gdi+ grantorrevokepermissionthroughc#.net gtk hospitalmanagementinformationsystem httpwebrequest image index input install java label list listbox listener mandelbrot math mouseclick mysql operator oracle path photoshop picturebox pixelinversion platform post programming radians regex remote remoting richtextbox save saving serialization server sleep socket sql statistics stream string table tcp text textbox thread time timer update usercontrol validation view visualstudio webbrowser windows winforms wordautomation wpf xml






