本文整理汇总了C#中Utf8String.TrySubstringFrom方法的典型用法代码示例。如果您正苦于以下问题:C# Utf8String.TrySubstringFrom方法的具体用法?C# Utf8String.TrySubstringFrom怎么用?C# Utf8String.TrySubstringFrom使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Utf8String
的用法示例。
在下文中一共展示了Utf8String.TrySubstringFrom方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SubstringFromTests
public void SubstringFromTests(string expected, string s, string substring)
{
Utf8String utf8s = new Utf8String(s);
Utf8String utf8substring = new Utf8String(substring);
Utf8String result;
Assert.Equal(expected != null, utf8s.TrySubstringFrom(utf8substring, out result));
if (expected != null)
{
Utf8String utf8expected = new Utf8String(expected);
Assert.Equal(expected, result.ToString());
Assert.Equal(utf8expected, result);
}
}
示例2: SubstringFromCodeUnit
public void SubstringFromCodeUnit(string s, char c)
{
Utf8String u8s = new Utf8String(s);
Utf8CodeUnit codeUnit = (Utf8CodeUnit)(byte)(c);
Utf8String u8result;
int idx = s.IndexOf(c);
bool expectedToFind = idx != -1;
Assert.Equal(expectedToFind, u8s.TrySubstringFrom(codeUnit, out u8result));
if (expectedToFind)
{
string expected = s.Substring(idx);
Assert.Equal(new Utf8String(expected), u8result);
Assert.Equal(expected, u8result.ToString());
}
}