Esempio n. 1
0
        private static void Main(string[] args)
        {
            var classExample     = new ClassExample(true, 111, 55.44);
            var classExampleCopy = classExample;

            classExample.Field1 = false;
            classExample.Field2 = 222;
            classExample.Field3 = 111.222;

            Console.WriteLine("Пример присвоения ссылки.");
            Console.WriteLine(classExample.Info);
            Console.WriteLine(classExampleCopy.Info);

            var structExample     = new StructExample(true, 111, 55.44);
            var structExampleCopy = structExample;

            structExample.Field1 = false;
            structExample.Field2 = 222;
            structExample.Field3 = 111.222;

            Console.WriteLine("Пример присвоения значения.");
            Console.WriteLine(structExample.Info);
            Console.WriteLine(structExampleCopy.Info);

            Console.ReadLine();
        }
        public void Change_Reference_Types()
        {
            // Act
            var example1 = new ClassExample {
                Foo = InitialStr, Bar = InitialNumb
            };
            var example2 = example1;
            var example3 = new ClassExample {
                Foo = InitialStr, Bar = InitialNumb
            };
            var example4 = new ClassExample();

            // Action
            example1.Foo = ResultStr;
            example1.Bar = ResultNumb;
            ModifyRefType(example3);

            // Assert
            Assert.NotNull(example1);
            Assert.NotNull(example2);
            Assert.NotNull(example3);
            Assert.NotNull(example4);

            // values are equal (include strings)
            Assert.Equal(ResultStr, example1.Foo);
            Assert.Equal(ResultNumb, example1.Bar);

            Assert.Equal(ResultStr, example2.Foo);
            Assert.Equal(ResultNumb, example2.Bar);

            Assert.Equal(ResultStr, example3.Foo);
            Assert.Equal(ResultNumb, example3.Bar);

            Assert.Equal(default, example4.Foo);
Esempio n. 3
0
        public void InstanceClassField()
        {
            var obj = new ClassExample();

            ExpressionUtil.GetSetter(() => obj.InstanceField)(TEST_VAL);
            Assert.Equal(TEST_VAL, obj.InstanceField);
        }
Esempio n. 4
0
        public static void ExecuteExample()
        {
            ClassExample ex  = new ClassExample();                                      //using the default cosntructor
            ClassExample ex2 = new ClassExample("Using the parameterized constructor"); //using the default cosntructor

            ex.Dispose();
            ex2.Dispose();
        }
Esempio n. 5
0
 static void ChangeExampleReference(ref ClassExample example)
 {
     example = new ClassExample
     {
         Foo = "3",
         Bar = 3
     };
 }
Esempio n. 6
0
 static void Main(string[] args)
 {
     Basic.Example.Main();
     IsA_Namespace.Example.Main();
     AccessExample.Main(args);
     Example.Example.Main();
     ClassNameExample.Main();
     ClassExample.Main();
 }
Esempio n. 7
0
        public static void Main(string[] args)
        {
            Console.WriteLine("Welcome to an Interface Example in C#");
            ClassExample ex = new ClassExample();

            Console.WriteLine("The sum of 5 and 6 is: " + ex.add(5, 6));
            Console.WriteLine("Press any key to continue ....");
            Console.ReadKey();
        }
Esempio n. 8
0
    public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
    {
        ClassExample obj = value as ClassExample;

        if (obj != null)
        {
            return(obj.X);
        }
        return(0);
    }
Esempio n. 9
0
        static void ChangeExampleValues(ClassExample example)
        {
            example.Bar = 2;
            example.Foo = "2";

            example = new ClassExample
            {
                Foo = "secondary-string-literal",
                Bar = 222
            };
        }
Esempio n. 10
0
    public override void InitializeNewDomain(AppDomainSetup appDomainInfo)
    {
        //Set Break here, Dump Stack. You should be in System.AppDomain.CreateAppDomainManager();

        System.Windows.Forms.MessageBox.Show("AppDomain - KaBoomBeacon!");

        // You have more control here than I am demonstrating. For example, you can set ApplicationBase,
        // Or you can Override the Assembly Resolver, etc...
        bool res = ClassExample.Execute();

        return;
    }
Esempio n. 11
0
        private static void Main(string[] args)
        {
            var classExample = new ClassExample(true, 111, 55.44);

            ClassMethod(classExample);

            Console.WriteLine("Пример передачи в метод экземпляра класса.");
            Console.WriteLine(classExample.Info);

            var structExample = new StructExample(true, 111, 55.44);

            StructMethod(structExample);

            Console.WriteLine("Пример передачи в метод экземпляра структуры.");
            Console.WriteLine(structExample.Info);
            Console.ReadLine();
        }
Esempio n. 12
0
        static void ClassInAction()
        {
            var rfEx1 = new ClassExample()
            {
                Foo = "initial-string-literal", Bar = 123
            };

            var rfEx2 = rfEx1;                          // rfEx2.Foo="initial-string-literal", rfEx2.Bar=123

            rfEx1.Foo = "1";                            // rfEx1.Foo="1", rfEx2.Foo="1"
            rfEx1.Bar = 1;                              // rfEx1.Bar=1, rfEx2.Bar=1

            ChangeExampleValues(rfEx1);                 // rfEx1.Foo="2", rfEx2.Foo="2"
                                                        // rfEx1.Bar=2, rfEx2.Bar=2

            ChangeExampleReference(ref rfEx1);          // rfEx1.Foo="3", rfEx2.Foo="2"
                                                        // rfEx1.Bar=3, rfEx2.Bar=2

            rfEx1.Foo = "4";                            // rfEx1.Foo="4", rfEx2.Foo="2"
            rfEx1.Bar = 4;                              // rfEx1.Bar=4, rfEx2.Bar=2
        }
Esempio n. 13
0
        static void Main(string[] args)
        {
            //Array array = new string[5];
            ArrayList humans = new ArrayList();

            humans.Add("Dima");
            humans.Add("Kolyan");
            humans.Add("Petya");

            foreach (var human in humans)
            {
                Console.WriteLine(human);
            }

            humans.Remove("Kolyan");
            Console.WriteLine("----------");

            foreach (var human in humans)
            {
                Console.WriteLine(human);
            }
            Console.WriteLine("**** foreach через приватный метод");

            foreach (var human in humans)
            {
                Output(human);
            }

            MyStack();
            MyQueue();
            MyHash();
            ExampleLinkedList();

            //Dictionary<IDescription, IFruit> fruit = new Dictionary<IDescription, IFruit>();
            ClassExample.DictionaryInterface();

            Console.ReadKey();
        }
Esempio n. 14
0
        static void Main(string[] args)
        {
            ClassExample example = new ClassExample();

            example.FirstClass();
        }
Esempio n. 15
0
        public void Calcolo1Test()
        {
            bool resp = ClassExample.Calcolo1();

            Assert.AreEqual(true, resp);
        }
Esempio n. 16
0
        public static void TestMethod()
        {
            ClassExample example = new ClassExample();

            Console.WriteLine(example.MessageFromAssembly("Nicolai"));
        }
Esempio n. 17
0
 // Классы передают в метод ссылку.
 private static void ClassMethod(ClassExample classExample)
 {
     classExample.Field1 = false;
     classExample.Field2 = 222;
     classExample.Field3 = 111.222;
 }