例如,VB中: Dim strsde As String
           strsde="456123.25"
           Dim pos As Long
           pos = InStrRev(strsde, ".")
其中,InStrRev函数:返回某一字符串从另一字符串的右侧开始算起第一次出现的位置.在C#里应怎样实现   大侠帮忙啊......

解决方案 »

  1.   

    string strsde = "456123.25";
    long pos = strsde.IndexOf(".");
      

  2.   

    pos = fileName.IndexOf(".");
      

  3.   

    public int LastIndexOf(string value)
        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.
      

  4.   

    IndexOf\LastIndexOf都是从左算起  怎样从右开始算起
      

  5.   

    似乎没有...用LastIndexOf不能实现吗?把你的需求说一下..
      

  6.   

    LastIndexOf返回的是最后一个匹配项的索引位置pos = InStrRev(strsde, ".")
    像InStrRev函数:返回某一字符串从另一字符串的右侧开始算起第一次出现的位置
      

  7.   

    是这个意思吗?string str = "aaa.bbb.ccc";
                int index = str.Length-1 - str.LastIndexOf(".");输出index是3
      

  8.   

    using System;
    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
            }
        }
    }