strsde="456123.25"
Dim pos As Long
pos = InStrRev(strsde, ".")
其中,InStrRev函数:返回某一字符串从另一字符串的右侧开始算起第一次出现的位置.
在C#里应怎样实现 大侠帮忙啊......
18 个解决方案
#1
string strsde = "456123.25";
long pos = strsde.IndexOf(".");
long pos = strsde.IndexOf(".");
#2
pos = fileName.IndexOf(".");
#3
IndexOf
LastIndexOf
LastIndexOf
#4
IndexOf
#5
public int LastIndexOf(string value)
Member of System.String
Summary:
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.
Member of System.String
Summary:
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.
#6
String.IndexOf(string)
#7
lastIndexOf();
#8
IndexOf\LastIndexOf都是从左算起 怎样从右开始算起
#9
似乎没有...
用LastIndexOf不能实现吗?
把你的需求说一下..
用LastIndexOf不能实现吗?
把你的需求说一下..
#10
IndexOf
LastIndexOf
LastIndexOf
#11
string1.IndexOf(string2)
#12
str.indexOf(str,".")
#13
LastIndexOf返回的是最后一个匹配项的索引位置
pos = InStrRev(strsde, ".")
像InStrRev函数:返回某一字符串从另一字符串的右侧开始算起第一次出现的位置
pos = InStrRev(strsde, ".")
像InStrRev函数:返回某一字符串从另一字符串的右侧开始算起第一次出现的位置
#14
是这个意思吗?
string str = "aaa.bbb.ccc";
int index = str.Length-1 - str.LastIndexOf(".");
输出index是3
string str = "aaa.bbb.ccc";
int index = str.Length-1 - str.LastIndexOf(".");
输出index是3
#15
对 也是这么做得 就是想不知道C#里有没有更好的实现方法
#16
没有直接的函数,这个不就行了吗?
也不复杂吧..
也不复杂吧..
#17
#18
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
}
}
}
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
}
}
}
#1
string strsde = "456123.25";
long pos = strsde.IndexOf(".");
long pos = strsde.IndexOf(".");
#2
pos = fileName.IndexOf(".");
#3
IndexOf
LastIndexOf
LastIndexOf
#4
IndexOf
#5
public int LastIndexOf(string value)
Member of System.String
Summary:
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.
Member of System.String
Summary:
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.
#6
String.IndexOf(string)
#7
lastIndexOf();
#8
IndexOf\LastIndexOf都是从左算起 怎样从右开始算起
#9
似乎没有...
用LastIndexOf不能实现吗?
把你的需求说一下..
用LastIndexOf不能实现吗?
把你的需求说一下..
#10
IndexOf
LastIndexOf
LastIndexOf
#11
string1.IndexOf(string2)
#12
str.indexOf(str,".")
#13
LastIndexOf返回的是最后一个匹配项的索引位置
pos = InStrRev(strsde, ".")
像InStrRev函数:返回某一字符串从另一字符串的右侧开始算起第一次出现的位置
pos = InStrRev(strsde, ".")
像InStrRev函数:返回某一字符串从另一字符串的右侧开始算起第一次出现的位置
#14
是这个意思吗?
string str = "aaa.bbb.ccc";
int index = str.Length-1 - str.LastIndexOf(".");
输出index是3
string str = "aaa.bbb.ccc";
int index = str.Length-1 - str.LastIndexOf(".");
输出index是3
#15
对 也是这么做得 就是想不知道C#里有没有更好的实现方法
#16
没有直接的函数,这个不就行了吗?
也不复杂吧..
也不复杂吧..
#17
#18
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
}
}
}
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
}
}
}