Advertisement
Guest User

Untitled

a guest
Nov 18th, 2016
415
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.92 KB | None | 0 0
  1. using System;
  2.  
  3. namespace Answer
  4. {
  5.     class Test
  6.     {
  7.         private string[] _stringArray = new string[2];
  8.         public string[] StringArray
  9.         {
  10.             get { return _stringArray; }
  11.             set
  12.             {
  13.                 //value = массив
  14.                 if (value.Length == _stringArray.Length) {
  15.                     for (int index = 0; index < value.Length; index++) {
  16.                         string element = value[index];
  17.                         _stringArray[index] = element;
  18.                     }
  19.                 }
  20.             }
  21.         }
  22.     }
  23.  
  24.     class Program
  25.     {
  26.         static void Main(string[] args)
  27.         {
  28.             var test = new Test();
  29.  
  30.             test.StringArray = new string[] { "Abra", " Cadabra" };
  31.  
  32.             Console.Write(test.StringArray[0]);
  33.             Console.Write(test.StringArray[1]);
  34.  
  35.             Console.WriteLine();
  36.         }
  37.     }
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement