Пример #1
0
 public Galaxy(
     int id,
     string name,
     GalaxyClass galaxyClass,
     decimal rotationalSpeedInKph,
     decimal solarMass,
     Point3D location
     )
 {
     this.Id                   = id;
     this.Name                 = name;
     this.GalaxyClass          = galaxyClass;
     this.RotationalSpeedInKph = rotationalSpeedInKph;
     this.SolarMass            = solarMass;
     this.Location             = location;
     this.Stars                = new List <Star>();
 }
Пример #2
0
        static void Main(string[] args)
        {
            int power = 0;

            // Display powers of 2 up to the exponent of 8:
            foreach (int i in PowersOf2.Power(2, 8))
            {
                power += 1;
                Console.WriteLine("2^{0} = {1} ", power, i);
            }
            // Display powers of 2 up to the exponent of 8:
            power = 0;
            foreach (int i in PowersOf2.Power(2, 8))
            {
                power += 1;
                Console.WriteLine("2^{0} = {1} ", power, i);
            }

            GalaxyClass.ShowGalaxies();
        }
Пример #3
0
        static void Main(string[] args)
        {
            Console.WriteLine("Hello World!");
            Class1 c1 = new Class1();

            Console.WriteLine($"Hello,World {c1.ReturnMessage()} \n");

            Sample sample = new Sample();

            Console.WriteLine($"Search Result : {sample.Search()}");

            Fibonacci fib = new Fibonacci();

            fib.generateFibonacci();

            AccessModifierPublic classPublic = new AccessModifierPublic(45);

            // public method
            classPublic.AreaOfCircle();

            // internal method
            classPublic.perimeterOfCircleInternal();

            // public method bypass for protected method and private method
            // classPublic.perimeterOfCircleBypass();

            // private method cannot be accessed
            // classPublic.perimeterOfCirclePrivate();

            // protectected method cannot be accessed
            // classPublic.perimeterOfCircleProtected

            // call main method of another class
            AccessModifierPublic.main(null);

            // static class method cannot be accessed by instance but by classname itself
            StaticClass.StaticMessage();

            ContactStaticClass.main(null);

            // from namespace iterators ,accessing static method
            ForeachExamples.ExampleOne();

            // calling main
            PowerOf2 power = new PowerOf2();

            PowerOf2.main(null);

            // calling main of static class
            GalaxyClass.main(null);

            Console.Clear();

            foreach (var item in IteratorMethods.GetSingleDigitNumbers())
            {
                Console.WriteLine(item);
            }

            foreach (var item in IteratorMethods.GetSingleDigitNumbersV2())
            {
                Console.WriteLine(item);
            }

            Console.WriteLine("\nGeneric Array ");

            GenericArray <int> genericArray = new GenericArray <int>(5);

            genericArray.setItem(0, 1);

            Console.WriteLine(genericArray.getItem(0));

            // will produce assertion error by making assertion false message displays
            Console.WriteLine(genericArray.getItem(6));

            Console.Clear();
        }