本文整理汇总了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();
}
示例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
//.........这里部分代码省略.........