例如,VB中: Dim strsde As String
strsde="456123.25"
Dim pos As Long
pos = InStrRev(strsde, ".")
其中,InStrRev函数:返回某一字符串从另一字符串的右侧开始算起第一次出现的位置.在C#里应怎样实现 大侠帮忙啊......
strsde="456123.25"
Dim pos As Long
pos = InStrRev(strsde, ".")
其中,InStrRev函数:返回某一字符串从另一字符串的右侧开始算起第一次出现的位置.在C#里应怎样实现 大侠帮忙啊......
long pos = strsde.IndexOf(".");
Member of System.StringSummary:
Reports the index position of the last occurrence of a specified System.String within this instance.Parameters:
value: A System.String to seek. Returns:
The index position of value if that string is found, or -1 if it is not. If value is System.String.Empty, the return value is the last index position in value.
像InStrRev函数:返回某一字符串从另一字符串的右侧开始算起第一次出现的位置
int index = str.Length-1 - str.LastIndexOf(".");输出index是3
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Microsoft.VisualBasic;
using Microsoft.VisualBasic.CompilerServices;namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
test();
}
private void test()
{
string str="abcdefghijklmnopqrstuvwxyz";
label1.Text = Strings.Left(str, 5);
label2.Text = Strings.Right(str, 5);
label3.Text = str.Substring(0,5);//Left
label4.Text = str.Substring(str.Length - 5);//Right
}
}
}