Example #1
0
 static void Main()
 {
     StringBuilder builder = new StringBuilder();
     builder.Append("The special love I have for you! My baby blue");
     Console.WriteLine(builder.SubString(12, 4));
     Console.WriteLine(builder.SubString(33));
 }
        static void Main()
        {
            StringBuilder theString = new StringBuilder();
            theString.Append("0123456789");

            Console.WriteLine(theString.SubString(5));
            Console.WriteLine(theString.SubString(2, 5));
        }
 static void Main()
 {
     // Test the extension method
     StringBuilder testSb = new StringBuilder();
     testSb.Append("Pesho and Gosho are the best of friends!");
     Console.WriteLine(testSb.SubString(10, 5)); // Gosho
     Console.WriteLine(testSb.SubString(0, 5)); // Pesho
 }
Example #4
0
        private static void Main()
        {
            StringBuilder someStringBuilder = new StringBuilder("Retrieves a substring from this instance. The substring starts at a specified character position and continues to the end of the string.");

            //// index
            Console.WriteLine(someStringBuilder.SubString(42));
            //// index ,length
            Console.WriteLine(someStringBuilder.SubString(0, 41));
        }
Example #5
0
 static void Main()
 {
     string str = "asdAsd";
     Console.WriteLine(str.Substring(1));
     Console.WriteLine(str.Substring(1,3));
     StringBuilder sb = new StringBuilder("asdasd");
     Console.WriteLine(sb.SubString(3,3));
     Console.WriteLine( sb.SubString(0, 3));
 }
        static void Main(string[] args)
        {
            string s = "MickiMouseManagement";

            StringBuilder sb = new StringBuilder(s);

            Console.WriteLine(sb.SubString(0, 5).ToString());

            Console.WriteLine(sb.SubString(5, 5).ToString());

            Console.WriteLine(sb.SubString(10, 10).ToString());
        }
 // Implement an extension method Substring(int index, int length) for the class StringBuilder
 // that returns new StringBuilder and has the same functionality as Substring in the class String.
 static void Main()
 {
     string text = "Pesho";
     Console.WriteLine(text.Substring(1, 3));// testing substring of string
     Console.WriteLine(text.Substring(2));
     StringBuilder sb = new StringBuilder();
     sb.Append("Gosho");
     sb.Append("Milena");
     Console.WriteLine(sb.SubString(1,2).ToString());
     Console.WriteLine(sb.SubString(1, 9).ToString());//testing substring of StringBuilder
     Console.WriteLine(sb.Substring(3));
 }
Example #8
0
 static void Main()
 {
     StringBuilder test = new StringBuilder();
     test.AppendLine("This is testing string");
     string result = test.SubString(2, 3).ToString();
     Console.WriteLine(result);
 }
Example #9
0
        static void Main(string[] args)
        {
            string someText = "alabalanica";
            StringBuilder someString = new StringBuilder(someText);

            Console.WriteLine(someString.SubString(1,7).ToString());
        }
   static void Main(string[] args)
   {
       StringBuilder test = new StringBuilder();
       test.Append("ABCDIFGH");
       Console.WriteLine(test.SubString(5, 2).ToString());
 
   }
Example #11
0
 //Implement an extension method Substring(int index, int length) for the class StringBuilder that returns new StringBuilder
 //and has the same functionality as Substring in the class String.
 static void Main(string[] args)
 {
     StringBuilder testing = new StringBuilder();
     testing.AppendLine("Some text"); // the bellow values are hardcoded for the examplary function of the task
     Console.WriteLine(testing.SubString(2, 2).ToString());   //takes an index and from it with the specified length returns
                                                             //a stringBuilder value of the one that was passed
 }
Example #12
0
        public static void Main()
        {
            var builder = new StringBuilder("StringBuilder in the house!");

            var subBuilder = builder.SubString(0, 13);

            Console.WriteLine(subBuilder);
        }
 static void Main(string[] args)
 {
     StringBuilder str = new StringBuilder();
     str.Append("Abra cadabra sin salabim");
     int index = 1;
     int lenght = 7;
     Console.WriteLine(str.SubString(index,lenght).ToString());
     
 }
 static void Main()
 {
     StringBuilder sb = new StringBuilder();
     for (int i = 0; i < 10; i++)
     {
         sb.Append("Some text ");
     }
     string str = sb.SubString(1, 7);
     Console.WriteLine(str);
 }
Example #15
0
        static void Main(string[] args)
        {
            //Testing
            StringBuilder test = new StringBuilder();
            StringBuilder result = new StringBuilder();
            string sampleText = "Test me please.";

            test.Append(sampleText);
            result = test.SubString(14,0);
            Console.WriteLine(result);
   
        }
Example #16
0
        static void Main()
        {
            //test for Substring extension method
            StringBuilder demoString = new StringBuilder("Hello Kitty");
            Console.WriteLine(demoString.SubString(9, 2));

            //test for sum, product, min, max and average extension methods for IEnumerable<T>
            int[] demoCollection = {-2, -1};
            //Console.WriteLine(IEnumExtensions.Sum(demoCollection));
            //Console.WriteLine(IEnumExtensions.Product(demoCollection));
            Console.WriteLine(IEnumExtensions.Min(demoCollection));
            Console.WriteLine(IEnumExtensions.Max(demoCollection));
            //Console.WriteLine(IEnumExtensions.Average(demoCollection));
        }
        private static void Main(string[] args)
        {
            var b = new StringBuilder("qwjkhf");
            Console.WriteLine(b.SubString(3, 1));

            string[] str = {"pencho", "haralambi"};
            Console.WriteLine(str.Sum());
            Console.WriteLine(str.Min());

            int[] arr = {1, 2, 3};
            Console.WriteLine(arr.Sum());
            Console.WriteLine(arr.Min());
            Console.WriteLine(arr.Product());
            Console.WriteLine(arr.Average());
        }
Example #18
0
        static void Main(string[] args)
        {
            StringBuilder tmp = new StringBuilder("Pesho, Kiro, kiro, Stamat");

            int[] nums = new int[5]{1, 2, 3, 4, 5};
            List<string> names = new List<string> { "Evgeni", "Lora", "Bai Ivan" };

            String subStr = tmp.SubString(7, 4);
            Console.WriteLine(subStr);
            Console.WriteLine();

            Console.WriteLine(tmp.RemoveText(" kiro,"));
            Console.WriteLine();

            tmp.AppendAll<int>(nums);
            tmp.AppendAll<string>(names);
            Console.WriteLine(tmp);
        }
Example #19
0
        public static void Main()
        {
            StringBuilder sb = new StringBuilder();
            sb.Append("Pesho");
            sb.Append("Gosho");
            sb.Append("Valio");
            sb.Append("Mitko");
            sb.Append("Ganio");
            sb.Append("Traicho");
            sb.Append("Simo");
            sb.Append("Valentin");
            sb.Append("Valentinka");
            sb.Append("Nikolaika");
            sb.Append("Gaika");
            sb.Append("Petranka");
            Console.WriteLine("The result from extension method:");
            Console.WriteLine(sb.SubString(0, 10));

            Console.WriteLine("The result from normal string:");
            string str = "PeshoGoshoValioMitkoGanioGosho";
            Console.WriteLine(str.Substring(0, 10));
        }
 static void Main(string[] args)
 {
     var pesho = new StringBuilder();
     pesho.AppendLine("hello");
     Console.WriteLine(pesho.SubString(0,2));
 }
	public void SubString_GetSubStringByLength()
	{
		StringBuilder builder = new StringBuilder();
		builder.Append("abcdefg");
		string subStr = builder.SubString(2, 2);
		Assert.IsTrue(subStr == "cd");
	}
	public void SubString_ContainsNonAsciiCharacters()
	{
		StringBuilder builder = new StringBuilder();
		builder.Append("\u3041\u3042\u3043\u3044\u3045");
		string subStr = builder.SubString(2,2);
		Assert.IsTrue(subStr == "\u3043\u3044");
	}
	public void SubString_LengthIsZero()
	{
		StringBuilder builder = new StringBuilder();
		builder.Append("abcdefg");
		builder.SubString(3, 0);
	}
	public void SubString_LengthTooLong()
	{
		StringBuilder builder = new StringBuilder();
		builder.Append("abcdefg");
		builder.SubString(0, 10);
	}
	public void SubString_StartIndexIsLessThanZero()
	{
		StringBuilder builder = new StringBuilder();
		builder.Append("abcdefg");
		builder.SubString(Int32.MinValue);
	}
	public void SubString_StartIndexIsZero()
	{
		StringBuilder builder = new StringBuilder();
		builder.Append("abcdefg");
		string subStr = builder.SubString(0);
		Assert.IsTrue(subStr == "abcdefg");
	}
	public void SubString_StringBuilderEmpty()
	{
		StringBuilder builder = new StringBuilder();
		builder.Append(string.Empty);
		builder.SubString(0);
	}
 static void Main() 
 {
     StringBuilder strBuild = new StringBuilder("What the fuck are you talkink about");
     Console.WriteLine(strBuild.SubString(9, 4));
 }
Example #29
0
 static void Main(string[] args)
 {
     StringBuilder sb = new StringBuilder("Extending StringBuilder");
     Console.WriteLine(sb.SubString(10,13));
 }
Example #30
0
 static void Main()
 {
     StringBuilder text = new StringBuilder();
     text.Append("some line to add");
     Console.WriteLine(text.SubString(2,5).ToString());
 }