void Start()
    {
        var w0 = Tuple1.a('3');

        Debug.Log(w0.value);
        var w2 = w0.add("5");

        Debug.Log(w2._1 + w2._2);

        var r0 = Recursive.a(3);

        Debug.Log(r0.value);
        var r1 = r0.wrap();

        Debug.Log(r1.value.value);
        var r2 = r1.wrap();

        Debug.Log(r2.value.value.value);
        var r21 = r0.wrap2(3);

        Debug.Log(r21.value._1 + r21.value._2);
        var r22 = r21.wrap2(5);

        Debug.Log(r22.value._1._1 + r22.value._1._2 + r22.value._2);
    }
    public static void testLinqSelect()
    {
        var intWrappers = new[] { new IntWrapper(3) };
        //  Subject<Collider2D>[] observables = (from b in componentsInChildren
        //  select b.gameObject.AddComponent<Trigger2D>().triggerEnter).ToArray<Subject<Collider2D>>();
//    var b = intWrappers.Select(x => Tuple1.a(x.value)).ToArray();
        var b = (from x in intWrappers select Tuple1.a(x.value)).ToArray();
    }
 public Recursive <Tuple1 <A> > wrap()
 {
     return(Recursive.a(Tuple1.a(value)));
 }
 public static void testGenericArrayViaGenericStatic()
 {
     var x = Tuple1 <int> .arrIdentity(new[] { 1 });
 }
 public static void testGenericMethodInGenericClass()
 {
     var intT = new Tuple1 <int>(3).add("4");
     var strT = new Tuple1 <string>("3").add(4);
 }
 public static void testGenericInstanceViaStaticGenericMethodInSimpleClass()
 {
     var intT = Tuple1.a(3);
     var strT = Tuple1.a("3");
 }
    public static void testGenericInstanceViaStaticMethodInGenericClass()
    {
        var intT = Tuple1 <int> .a(3);

        var strT = Tuple1 <string> .a("3");
    }
 public static void testGenericStructCtor()
 {
     var intT = new Tuple1 <int>(3);
     var strT = new Tuple1 <string>("3");
 }
    public static void testStaticMethodInGenericClass()
    {
        var intId = Tuple1 <int> .identity(3);

        var strId = Tuple1 <string> .identity("3");
    }
 public static void testGenericStaticMethodInSimpleClass()
 {
     var intId = Tuple1.identity(3);
     var strId = Tuple1.identity("3");
 }
Exemple #11
0
        static void Main(string[] args)
        {
            //a)Типы данных
            Byte    a = 0;
            SByte   b = 127;
            short   c = 32_767;
            ushort  d = 65_535;
            Int32   e = 2_147_483_647;
            UInt32  f = 4_294_967_295;
            Int64   g = 9_223_372_036_854_775_807; //Long
            UInt64  h = 18_446_744_073_709_551_615;
            Single  i = 3.5f;                      //Float
            Double  k = 1.4128947129487192;
            Decimal j = 7.992285235235235m;

            Char[]             y         = { 'C', 'и', 'м', 'в', 'о', 'л', ' ', 'Ю', 'н', 'и', 'к', 'о', 'д', 'а' };
            String             t         = "Строка символов Юникода";
            var                variation = 6;
            Boolean            z         = true;
            Object             x         = g;
            Int32?             Nul       = null;
            Nullable <Int32>   Nulable   = 5;
            Nullable <Boolean> enable    = null;

            //b) Приведение типов данных(явное - неявное)
            g = e;                   //Неявное преобразование
            Int32 var  = 5;
            Int16 var2 = (Int16)var; // Явное, так как Int32 производная от Int16
            //Приведение при помощи is
            Object  o  = new Object();
            Boolean b1 = (o is Object);
            Boolean b2 = (o is Boolean);

            Console.WriteLine(b1);
            Int32 a1 = 1;
            Int32 a2 = 1;

            for (int i1 = 0; i1 < var; i1++)
            {
                a1 = var2;
                Int32 var4 = var2;
                var4 = var4 - 1;
                var2 = (Int16)var4;
                a2   = a2 * a1;
            }
            Console.WriteLine(a2);

            //Строковые литералы
            String First  = "Привет.";
            String Second = "Как дела?";

            Console.WriteLine(Second.Equals(First));


            String Third          = "Познакомимся?";
            String CompliteString = String.Format("{0}{1}{2}", First, Second, Third);

            Console.WriteLine(CompliteString);

            CompliteString = String.Copy(First);
            Console.Write(CompliteString);

            CompliteString = Second.Substring(4, 5);
            Console.WriteLine(CompliteString);

            CompliteString = String.Format("{0}{1}{2}", First, Second, Third);
            String StringForSplit = "Привет Как дела Познакомимся";

            String[] Words = StringForSplit.Split(' ');
            for (int i1 = 0; i1 < 3; i1++)
            {
                Console.WriteLine(Words[i1]);
            }

            CompliteString = Second.Substring(4, 4);
            Second         = Second.Insert(9, CompliteString);
            Console.WriteLine(Second);

            CompliteString = Second.Remove(0, 10);
            Console.WriteLine(CompliteString);

            String EmptyString = "";
            String NullString  = null;

            Console.WriteLine(EmptyString.Length);
            //Console.WriteLine(NullString.Length); - Нулл не вернёт значений
            Console.WriteLine();

            StringBuilder stringBuilder = new StringBuilder("Привет.Как дела? Познакомимся?", 50);

            stringBuilder.Insert(0, "Оу.");
            stringBuilder.AppendFormat("Сегодня хорошая погода.");
            Console.WriteLine(stringBuilder);
            Console.WriteLine();

            //Массивы
            int[,] FirstArr = new int[4, 4];
            for (int i1 = 0; i1 < 4; i1++)
            {
                for (int j1 = 0; j1 < 4; j1++)
                {
                    FirstArr[i1, j1] = i1 + j1;
                    Console.Write(FirstArr[i1, j1] + " ");
                }
                Console.WriteLine();
            }
            Console.WriteLine(FirstArr[1, 2]);

            String[] StringArr = new string[4];
            Console.WriteLine();
            Console.Write("Введите содержимое массива: ");
            for (int i1 = 0; i1 < StringArr.Length; i1++)
            {
                Console.Write("[" + (i1 + 1) + "] - ");
                StringArr[i1] = Console.ReadLine();
            }
            Console.WriteLine();
            for (int i1 = 0; i1 < StringArr.Length; i1++)
            {
                Console.WriteLine("[" + (i1 + 1) + "] - " + StringArr[i1]);
            }
            Console.WriteLine("Размер массива: " + StringArr.Length);
            Console.WriteLine();

            Console.WriteLine("Введите позицию элемента в массиве и его новое содержимое:");
            Console.Write("Позиция(Максимальное число позиций[" + StringArr.Length + "]): ");
            String PositionString = Console.ReadLine();
            Int32  PositionInt    = Convert.ToInt32(PositionString);

            PositionInt = PositionInt - 1;
            Console.Write("Содержимое: ");
            String Content = Console.ReadLine();

            StringArr[PositionInt] = Content;
            for (int i1 = 0; i1 < StringArr.Length; i1++)
            {
                Console.WriteLine("[" + (i1 + 1) + "] - " + StringArr[i1]);
            }

            Int32[][] JaggedArr = new Int32[3][];
            JaggedArr[0] = new Int32[2];
            JaggedArr[1] = new Int32[3];
            JaggedArr[2] = new Int32[4];
            Console.WriteLine();
            Console.WriteLine("Ступенчатый массив:");
            for (int i1 = 0; i1 < 2; i1++)
            {
                JaggedArr[0][i1] = i1;
                Console.Write(JaggedArr[0][i1]);
            }
            Console.WriteLine();
            for (int i1 = 0; i1 < 3; i1++)
            {
                JaggedArr[1][i1] = i1 + 1;
                Console.Write(JaggedArr[1][i1]);
            }
            Console.WriteLine();
            for (int i1 = 0; i1 < 4; i1++)
            {
                JaggedArr[2][i1] = i1 + 2;
                Console.Write(JaggedArr[2][i1]);
            }
            Console.WriteLine();

            Object ArrayObj = new Object[0];
            // Одномерный ступенчатый массив
            var c1 = new[]
            {
                new[] { 1, 2, 3, 4 },
                new[] { 5, 6, 7, 8 }
            };

            //Кортежи
            (Int32, String)Tuple1 = (5, "Привет");
            var Tuple2 = (var1 : 5, var2 : "Привет");

            Console.WriteLine();
            Console.WriteLine("Значение 1 элемента кортежа 1 :" + Tuple1.Item1);
            Console.WriteLine("Значение 1 элемента кортежа 2 :" + Tuple2.var1);
            var Tuple3 = Tuple1 + Tuple2;

            Console.WriteLine("@@@@@@@@@@" + aaaa);
            var tuple = GetValue(("Tom", 25), 5);

            Console.WriteLine(tuple.Item1);
            Console.WriteLine(tuple.Item2);

            Console.WriteLine("Равны ли кортежи: " + Tuple1.Equals(Tuple2));


            (Int32, Int32, Int32, Char) MyFunction(Int32[] IntArr, String Stringm)
            {
                Int32  max = 0, summ = 0, min = IntArr[0];
                String FirstChar = "Привет";

                return(IntArr.Max(), IntArr.Min(), IntArr.Sum(), FirstChar.First());
            }

            Int32[] IntArr2 = new[] { 2, 2, 3, 2, 2 };
            var     tuple2  = MyFunction(IntArr2, "Привет");

            Console.WriteLine();
            Console.WriteLine(tuple2.Item1);
            Console.WriteLine(tuple2.Item2);
            Console.WriteLine(tuple2.Item3);
            Console.WriteLine(tuple2.Item4);
            Console.ReadKey()
        }
 public static void testGenericStructCtor()
 {
     var intT = new Tuple1<int>(3);
     var strT = new Tuple1<string>("3");
 }
 public static void testGenericMethodInGenericClass()
 {
     var intT = new Tuple1<int>(3).add("4");
     var strT = new Tuple1<string>("3").add(4);
 }