当前位置: 首页>>代码示例>>C#>>正文


C# Rectangle.Display方法代码示例

本文整理汇总了C#中Rectangle.Display方法的典型用法代码示例。如果您正苦于以下问题:C# Rectangle.Display方法的具体用法?C# Rectangle.Display怎么用?C# Rectangle.Display使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Rectangle的用法示例。


在下文中一共展示了Rectangle.Display方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ValueTypeContainingRefType

 static void ValueTypeContainingRefType() {
     Console.WriteLine("-> Creating r1");
     Rectangle r1 = new Rectangle("First Rect", 10, 10, 50, 50);
     //now assign a whole new Rectangle to r1....
     Console.WriteLine("-> Assigning r2 to r1");
     Rectangle r2 = r1;
     //change some values of r2...
     Console.WriteLine("-> Chaning values of r2");
     r2.rectInfo.infoString = "This is new info!";
     r2.rectBottom = 4444;
     //print both rectangles...
     r1.Display();
     r2.Display();
     
 }
开发者ID:lrymal,项目名称:Self-Study-C-Sharp,代码行数:15,代码来源:Program.cs

示例2: Main

        // the entry point for all C# programs. The Main method states what the class does when executed.
        static void Main(string[] args)
        {
            #region part2 - class, namespace, dynamic type, static methodes, convertions, constant, readonly, struct, generics, enums

            Console.WriteLine("\n\n\nPart 2: \n");

            #region simple class example

            // initialization methods:
            // 1:
            var rectangle1 = new Rectangle
            {
                Length = 10,
                Width = 6
            };

            // 2:
            var rectangle2 = new Rectangle(12, 8);

            // 3:
            var rectangle3 = new Rectangle();
            rectangle3.InitializeWithCustomValues();

            // 4:
            var rectangle4 = new Rectangle();
            rectangle4.InitializeWithSpecificValues(20, 15);

            // call methods:
            Console.WriteLine(rectangle1.GetArea());
            rectangle1.Display();
            Console.WriteLine(rectangle1.ToString());
            Console.ReadKey();

            Console.WriteLine(rectangle2.ToString());
            Console.ReadKey();

            Console.WriteLine(rectangle3.ToString());
            Console.ReadKey();

            Console.WriteLine(rectangle4.ToString());
            Console.ReadKey();

            // to do: GetPerimeter();

            #endregion

            #region namespace example

            Test3.MyMethode();

            #endregion

            #region satatic class, static methods, dynamic type example

            // dinamyc type: (with static class, static methode)
            Console.WriteLine();
            DynamicTypes.DynamicTypesExample();

            #endregion

            #region var, boxing and unboxing, conversion

            var val = 1;
            object obj = val; // boxing;
            int i = (int)obj; // unboxing;

            // cast double to int.
            double nr1 = 5673.74;
            int nr2 = (int) nr1;
            Console.WriteLine("nr = {0}, type = {1}", nr1, nr1.GetType());
            Console.WriteLine("nr = {0}, type = {1}", nr2, nr2.GetType());
            Console.ReadKey();

            #endregion

            #region const, readonly

            // working with constants:
            Console.WriteLine("\n");
            Console.WriteLine("Enter Radius: ");
            try
            {
                var radius = Convert.ToDouble(Console.ReadLine());
                var circle = new CircleExampleWithConstants(radius);
                circle.DisplayArea();
            }
            catch (FormatException e)
            {
                Console.WriteLine(e.Message);
                Console.ReadKey();
            }

            #endregion

            // struct
            // generic types
            // enums
            // extension methods

//.........这里部分代码省略.........
开发者ID:claudiu-orosanu,项目名称:Fundamentals2016,代码行数:101,代码来源:Program.cs


注:本文中的Rectangle.Display方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。