Advertisement
Guest User

Untitled

a guest
Feb 21st, 2021
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.94 KB | None | 0 0
  1. //Rextester.Program.Main is the entry point for your code. Don't change it.
  2. //Microsoft (R) Visual C# Compiler version 2.9.0.63208 (958f2354)
  3.  
  4. using System;
  5. using System.Collections.Generic;
  6. using System.Linq;
  7. using System.Text.RegularExpressions;
  8.  
  9. namespace Rextester
  10. {
  11.     public class Program
  12.     {
  13.         public static void Main(string[] args)
  14.         {
  15.             //Your code goes here
  16.             string[] names = {"John", "Mick", "Jessica", "Nick", "Frank", "James", "Josh"};
  17.            
  18.             string name1 = names[0]; // первый элемент массива
  19.             string name2 = ArrGetItem<string>(names, 1); // первый элемент массива (index - 1)
  20.             Console.WriteLine("(name1): names[0] = \"{0}\" | (name2): ArrGetItem<string>(names, 1) = \"{1}\"", name1, name2);
  21.         }
  22.         public static T ArrGetItem<T>(T[] sourceArray, int index) => sourceArray[index - 1];      
  23.     }
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement