Example #1
0
        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());
        }
        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));
        }
Example #3
0
 static void Main()
 {
     // Testing the substring class in StringBuilder:
     StringBuilder testing = new StringBuilder();
     testing.Append("GugenheimAgugu");
     Console.WriteLine(testing.Substring(9, 5).ToString());
 }
Example #4
0
 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);
 }
        static void Main()
        {
            var text = new StringBuilder();
            text.Append("I am learning C sharp.");

            var subText = text.Substring(5, 8);

            Console.WriteLine(subText);
        }
        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));
        }
        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);
        }
 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);
 }
        static void Main()
        {
            string str = "Test of extention.";

            StringBuilder sb = new StringBuilder(str);

            sb = sb.Substring(1, 10);

            Console.WriteLine(sb);
        }
 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());
 }
        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));
        }