kisame1313

Утр. занятие 29.07

Jul 29th, 2017
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.51 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Collections;
  4.  
  5. namespace Programz
  6. {
  7.     public delegate void MD ();
  8.  
  9.     class Program
  10.     {
  11.  
  12.         public delegate string StringDel ( string text );
  13.  
  14.         static void Main ( string [] args )
  15.         {
  16.             string text = "Это мой рандомный текст";
  17.  
  18.             StringDel strDel = ReplaceSpaces;
  19.             strDel ( text );
  20.             strDel = RemoveSpaces;
  21.             strDel ( text );
  22.             strDel = ToJadenCase;
  23.             strDel ( text );
  24.  
  25.             Console.WriteLine ();
  26.  
  27.             strDel = ReplaceSpaces;
  28.             strDel += RemoveSpaces;
  29.             strDel += ToJadenCase;
  30.             strDel ( text );
  31.         }
  32.  
  33.         public static string ReplaceSpaces ( string text )
  34.         {
  35.             text = text.Replace (' ','-');
  36.             Console.WriteLine (text);
  37.             return text;
  38.         }
  39.  
  40.         public static string RemoveSpaces ( string text )
  41.         {
  42.             string[] str = text.Split ( ' ' );
  43.             string newText = string.Empty;
  44.  
  45.             for ( int i = 0 ; i < str.Length ; i++ )
  46.             {
  47.                 newText += str [i];
  48.             }
  49.  
  50.             Console.WriteLine ( newText );
  51.             return newText;
  52.         }
  53.  
  54.         public static string ToJadenCase ( string text )
  55.         {
  56.             string [] str = text.Split ( ' ' );
  57.             string newText = string.Empty;
  58.  
  59.             for ( int i = 0 ; i < str.Length ; i++ )
  60.             {
  61.                 char[] symbs = str [i].ToCharArray();
  62.                 symbs [0] = char.ToUpper ( symbs [0]);
  63.                 str [i] = string.Empty;
  64.                 for ( int j = 0 ; j < symbs.Length ; j++ )
  65.                 {
  66.                     str [i] += symbs[j];
  67.                 }
  68.                
  69.                 newText += str [i]+" ";
  70.             }
  71.  
  72.             Console.WriteLine ( newText );
  73.             return newText;
  74.         }
  75.     }
  76. }
Advertisement
Add Comment
Please, Sign In to add comment