c# - 什么是 C# 相当于 C 中的 strstr()?

标签 c# c

首先,有一个问题几乎完全匹配我的问题(strstr() equivalent in C#),但他指的是一种方法来做一个字节[]比较版本。

我正在寻找一个字符串比较,它输出 str2 在 str1 中第一次出现的索引,但找不到它!

string s1 = ("BetYouCantFooFind");
string s2 = ("Foo");

int idx = strstrC#(s1,s2);

肯定有等价物吗?

最佳答案

我认为您正在寻找 IndexOf :

int idx = s1.IndexOf(s2);

关于c# - 什么是 C# 相当于 C 中的 strstr()?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12734174/

相关文章:

c# - 在 ASP.NET 中检查单选按钮

c# - 为什么 IPEndPoint 将 Int64 和 Int32 作为参数?

c# - SpreadJS 在基于 Webpack 的 Angular 应用程序中不起作用

c# - 如何使用 C# .net 查找字符串中的最后一个字母

c++ - 我如何知道 IMAGE_THUNK_DATA 数组何时终止?

c - ld.exe : cannot open output file . ..:权限被拒绝

c - 如何从 C 运行 Windows 命令

c - C 新手,段错误?

android - 如何将Android ROM源码导入Android Studio?

c# - 没有连接可用于服务此操作 : ZRANGEBYSCORE redis