本文整理汇总了C#中StringBuilder.Substring方法的典型用法代码示例。如果您正苦于以下问题:C# StringBuilder.Substring方法的具体用法?C# StringBuilder.Substring怎么用?C# StringBuilder.Substring使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类StringBuilder
的用法示例。
在下文中一共展示了StringBuilder.Substring方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Main
static void Main(string[] args)
{
StringBuilder t = new StringBuilder("Axl Rose has an IQ above the avarage.");
StringBuilder firstPart = t.Substring(0, 12);
StringBuilder secondPart = t.Substring(32, 5);
Console.WriteLine(firstPart.ToString() + " " + secondPart.ToString());
}
示例2: Main
public static void Main()
{
StringBuilder sb = new StringBuilder("1234");
Console.WriteLine(sb.Substring(0));
Console.WriteLine(sb.Substring(0, 4));
Console.WriteLine(sb.Substring(3, 1));
Console.WriteLine(sb.Substring(3));
}
示例3: Main
static void Main()
{
// Testing the substring class in StringBuilder:
StringBuilder testing = new StringBuilder();
testing.Append("GugenheimAgugu");
Console.WriteLine(testing.Substring(9, 5).ToString());
}
示例4: Main
static void Main()
{
StringBuilder sb = new StringBuilder("Only THIS will remain after the substring.");
Console.WriteLine(sb);
sb = sb.Substring(5, 4);
Console.WriteLine(sb);
}
示例5: Main
static void Main()
{
var text = new StringBuilder();
text.Append("I am learning C sharp.");
var subText = text.Substring(5, 8);
Console.WriteLine(subText);
}
示例6: Main
static void Main()
{
Console.WriteLine("Enter a string: ");
string input = Console.ReadLine();
StringBuilder text = new StringBuilder(input);
Console.WriteLine("StringBuilder.Substring: {0}", text.Substring(1, 5));
Console.WriteLine("String.Substring: {0}", input.Substring(1, 5));
}
示例7: Main
static void Main()
{
StringBuilder test = new StringBuilder("Hello Extension Methods");
StringBuilder substring1 = test.Substring(3, 5);
StringBuilder substring2 = StringBuilderSubstring.Substring(test, 3, 5);
Console.WriteLine("Results should be the same =>\nsubstring1: {0}\nsubstring2: {1}", substring1, substring2);
}
示例8: Main
static void Main()
{
StringBuilder testExt = new StringBuilder();
testExt.Append("test1");
testExt.Append("test2");
testExt.Append("test3");
StringBuilder rezult = testExt.Substring(5, 5);
Console.WriteLine(rezult);
}
示例9: Main
static void Main()
{
string str = "Test of extention.";
StringBuilder sb = new StringBuilder(str);
sb = sb.Substring(1, 10);
Console.WriteLine(sb);
}
示例10: Main
public static void Main()
{
StringBuilder sb = new StringBuilder();
Console.WriteLine("Enter string:");
string input = Console.ReadLine();
Console.WriteLine("Enter index:");
int index = int.Parse(Console.ReadLine());
Console.WriteLine("Enter length:");
int length = int.Parse(Console.ReadLine());
sb.Append(input);
StringBuilder subStr = sb.Substring(index, length);
Console.WriteLine(subStr.ToString());
}
示例11: Main
static void Main()
{
string test = "abvgde";
Console.WriteLine( test.Substring(3, 3));
Console.WriteLine();
StringBuilder builder = new StringBuilder();
builder.Append("a");
builder.Append("b");
builder.Append("v");
builder.Append("g");
builder.Append("de");
// builder.Append("e");
Console.WriteLine(builder.Substring(3, 3));
}