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


C# Point.ToString方法代码示例

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


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

示例1: Main

 static void Main(string[] args)
 {
     var p = new Point(3, 5);
     System.Console.WriteLine("original point: " + p.ToString());
     BadSwapPoint(p);
     System.Console.WriteLine("after bad swap: " + p.ToString());
     GoodSwapPoint(ref p);
     System.Console.WriteLine("after good swap: " + p.ToString());
     //GoodSwapPoint(ref localPoint);
 }
开发者ID:transformersprimeabcxyz,项目名称:fig-keithshep,代码行数:10,代码来源:cstest.cs

示例2: Convert_to_a_string

 public void Convert_to_a_string()
 {
     var p = new Point(1, 2);
     var p2 = new Point(1, 1);
     Assert.That(p.ToString(), Is.EqualTo("(1,2)"));
     Assert.That(p2.ToString(), Is.EqualTo("(1,1)"));
 }
开发者ID:robdmoore,项目名称:gameoflife_csharp,代码行数:7,代码来源:PointTests.cs

示例3: Main3

 public static void Main3()
 {
     // Create two Point instances on the stack. 
     Point p1 = new Point(10, 10);
     Point p2 = new Point(20, 20);
     // p1 does NOT get boxed to call ToString (a virtual method). 
     Console.WriteLine(p1.ToString());// "(10, 10)" 
     // p DOES get boxed to call GetType (a non-virtual method). 
     Console.WriteLine(p1.GetType());// "Point" 
     // p1 does NOT get boxed to call CompareTo. 
     // p2 does NOT get boxed because CompareTo(Point) is called. 
     Console.WriteLine(p1.CompareTo(p2));// "-1" 
     // p1 DOES get boxed, and the reference is placed in c. 
     IComparable c = p1;
     Console.WriteLine(c.GetType());// "Point" 
     // p1 does NOT get boxed to call CompareTo. 
     // Since CompareTo is not being passed a Point variable, 
     // CompareTo(Object) is called which requires a reference to 
     // a boxed Point. 
     // c does NOT get boxed because it already refers to a boxed Point. 
     Console.WriteLine(p1.CompareTo(c));// "0" 
     // c does NOT get boxed because it already refers to a boxed Point. 
     // p2 does get boxed because CompareTo(Object) is called. 
     Console.WriteLine(c.CompareTo(p2));// "-1" 
     // c is unboxed, and fields are copied into p2. 
     p2 = (Point)c;
     // Proves that the fields got copied into p2. 
     Console.WriteLine(p2.ToString());// "(10, 10)" 
 }
开发者ID:eric7237cire,项目名称:CodeJam,代码行数:29,代码来源:Boxing1.cs

示例4: Main

    static void Main()
    {
        // Point p = new Point(); // uma instância em Stack => IL initobj

        Point p = new Point(7,9); // uma instância em Stack => call Point::.ctor(int32, int32)

        Console.WriteLine(p.ToString());

        object o = p; // box

        Console.WriteLine(o.ToString());
        Console.WriteLine(o.GetHashCode());

        // ((Point) o).y = 11; // Não se pode modificar uma versão temporária unbox
        // <=>

        // ((Point) o).SetY(11);// O objecto o NÃO foi modificado

        Setter i = (Setter) o;
        i.SetY(11);

        /*
        Point p2 = (Point) o; // unbox
        p2.y = 11; // modificar o objecto em Stack
        o = p2; // o passa a referenciar um novo objecto resultante do boxing
        */

        Console.WriteLine(o.ToString());
        Console.WriteLine(o.GetHashCode());
    }
开发者ID:JVinhais,项目名称:ave-2015-16-sem1-i41n,代码行数:30,代码来源:App.cs

示例5: FindAllPaths

    static void FindAllPaths(Point currentPoint, string path)
    {
        for (int i = 0; i < direction.GetLength(0); i++)
        {
            int newRow = currentPoint.Row + direction[i, 0];
            int newCol = currentPoint.Col + direction[i, 1];

            if (InBouds(labyrinth, newRow, newCol))
            {
                if (IsEnd(new Point(newRow, newCol)))
                {
                    Console.WriteLine("Path found: " + path);
                    PrintLabyrinth(labyrinth);
                }
                if (IsFree(labyrinth, newRow, newCol))
                {
                    labyrinth[newRow, newCol] = "X";
                    path += currentPoint.ToString();

                    FindAllPaths(new Point(newRow, newCol), path);
                    labyrinth[newRow, newCol] = "-";
                }
            }
        }
    }
开发者ID:skirov,项目名称:TA-CSharp,代码行数:25,代码来源:AllPathsInLabyrinth.cs

示例6: Main

 public static void Main()
 {
     Point p = new Point(7, 3);
     p.Print();
     Console.WriteLine(p.ToString()); // Redefinido em Point
     Console.WriteLine(p.GetType()); // box + call
     Console.WriteLine(p.GetHashCode()); // Herdado de Object
 }
开发者ID:Kadete,项目名称:ave-2013-14-sem2,代码行数:8,代码来源:PointApp.cs

示例7: Main

    static void Main() 
    {
        Point p1 = new Point(1,2);      // создаем объект Point

        Point p2 = p1.Copy();           // создаем копию первого объекта 
       
        Point p3 = p1;                  // создаем ссылку на первый объект

        
        Say("{0}\n", Object.ReferenceEquals(p1, p2));   // если ссылки неравны
        
        Say("{0}\n", Object.Equals(p1, p2));            // если объекты равны
        
        Say("{0}\n", Object.ReferenceEquals(p1, p3));   // если ссылки равны
        
        Say("p1's value is: {0}\n", p1.ToString());     // печать объект в строчном виде: (1, 2)
    }
开发者ID:akmaplus,项目名称:My_sources_cs,代码行数:17,代码来源:object.cs

示例8: OnPaint

    protected void OnPaint(object sender, PaintEventArgs e)
    {
        GraphicsUnit gUnit = GraphicsUnit.Pixel;

        Point renderingOrgPt = new Point(0, 0);
        renderingOrgPt.X = 100;
        renderingOrgPt.Y = 100;

        Graphics g = e.Graphics;

        g.PageUnit = gUnit;

        g.TranslateTransform(renderingOrgPt.X, renderingOrgPt.Y);
        g.DrawRectangle(new Pen(Color.Red, 1), 0, 0, 100, 100);

        this.Text = string.Format("PageUnit: {0}, Origin: {1}", gUnit, renderingOrgPt.ToString());
    }
开发者ID:dbremner,项目名称:hycs,代码行数:17,代码来源:helloGDIPlus.cs

示例9: DrawDirectEdge

        public void DrawDirectEdge(Point p1, Point p2, Color c)
        {
            Console.WriteLine("DrawDirecEdge with p1 = {0}, p2 = {1}, color = {2}", p1.ToString(), p2.ToString(), c.ToString());
            //Graphics g = this.CreateGraphics();

            // стрелка
            Pen p = new Pen(c);
            //g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
            //g.ScaleTransform(
            p.StartCap = System.Drawing.Drawing2D.LineCap.ArrowAnchor;
            p.CustomStartCap = new System.Drawing.Drawing2D.AdjustableArrowCap(8, 5, true);
            //p.EndCap = System.Drawing.Drawing2D.LineCap.ArrowAnchor;
            //p.DashStyle = System.Drawing.Drawing2D.DashStyle.Dash;

            g.DrawLine(p, p1.X, p1.Y, p2.X, p2.Y);

            //g.DrawLine(new Pen(c), p)
            //g.DrawLine(new Pen(c), p)
        }
开发者ID:autumnharmony,项目名称:GBusManager,代码行数:19,代码来源:GraphViewer.cs

示例10: AddMonsterFarFromLocation

        /// <summary>
        /// Add a monster with a random patrol. Needs the mapgenerator of the level in question
        /// </summary>
        /// <param name="monster"></param>
        /// <param name="mapGen"></param>
        private bool AddMonsterFarFromLocation(Monster monster, Point location, int level, MapGenerator mapGen)
        {
            //Offset location

            int maxLoops = 50;
            int loops = 0;

            Point toPlaceLoc = new Point(location);

            int distance = 40;

            do
            {
                toPlaceLoc = new Point(location.x + (int)Gaussian.BoxMuller(distance, 5), location.y + (int)Gaussian.BoxMuller(distance, 5));

                loops++;
                distance--;

            } while (!Game.Dungeon.AddMonster(monster, level, toPlaceLoc) && loops < maxLoops);

            if (loops == maxLoops)
            {
                LogFile.Log.LogEntryDebug("Failed to place: " + monster.Representation + " far from to: " + location + " reverting to random placement", LogDebugLevel.Medium);

                loops = 0;

                do
                {
                    toPlaceLoc = Game.Dungeon.RandomWalkablePointInLevel(level);
                    loops++;

                } while (!Game.Dungeon.AddMonster(monster, level, toPlaceLoc) && loops < maxLoops);

                LogFile.Log.LogEntryDebug("Failed to place: " + monster.Representation + " giving up", LogDebugLevel.High);
                return false;
            }

            LogFile.Log.LogEntryDebug("Item " + monster.Representation + " placed at: " + location.ToString(), LogDebugLevel.High);

            return true;
        }
开发者ID:Sinellil,项目名称:roguelike-cs,代码行数:46,代码来源:DungeonMaker.cs

示例11: AddItemCloseToLocation

        /// <summary>
        /// Tries to add an item close to a location, puts it anywhere if that's not possible
        /// </summary>
        /// <param name="item"></param>
        /// <param name="level"></param>
        /// <param name="location"></param>
        private bool AddItemCloseToLocation(Item item, int level, Point location)
        {
            //Offset location

            int maxLoops = 50;
            int loops = 0;

            Point toPlaceLoc = new Point(location);

            do
            {
                toPlaceLoc = new Point(location.x + (int)Gaussian.BoxMuller(2, 2), location.y + (int)Gaussian.BoxMuller(2, 2));
                loops++;

            } while (!Game.Dungeon.AddItem(item, level, toPlaceLoc) && loops < maxLoops);

            if (loops == maxLoops)
            {
                LogFile.Log.LogEntryDebug("Failed to place: " + item.Representation + " close to: " + location + " reverting to random placement", LogDebugLevel.Medium);

                loops = 0;

                do
                {
                    toPlaceLoc = Game.Dungeon.RandomWalkablePointInLevel(level);
                    loops++;

                } while (!Game.Dungeon.AddItem(item, level, toPlaceLoc) && loops < maxLoops);

                LogFile.Log.LogEntryDebug("Failed to place: " + item.Representation + " giving up", LogDebugLevel.High);
                return false;
            }

            LogFile.Log.LogEntryDebug("Item " + item.Representation + " placed at: " + location.ToString(), LogDebugLevel.High);

            return true;
        }
开发者ID:Sinellil,项目名称:roguelike-cs,代码行数:43,代码来源:DungeonMaker.cs

示例12: parseTypeL

    private void parseTypeL()
    {
        string[] life = msg.Split(':', '#');
        string[] position = life[1].Split(',');
        string lifeTime = life[2];

        Point p = new Point(int.Parse(position[0]), int.Parse(position[1]));
        gameInstance.addLifePack(p, int.Parse(lifeTime));

        Debug.Log("Life pack appears at " + p.ToString() + ". It will be there for " + lifeTime.ToString() + " time.");
    }
开发者ID:dulajperera,项目名称:Game_Tankers,代码行数:11,代码来源:Resolver.cs

示例13: parseTypeC

    private void parseTypeC()
    {
        string[] coins = msg.Split(':', '#');
        string[] position = coins[1].Split(',');
        string lifeTime = coins[2];
        int value = int.Parse(coins[3]);

        Point p = new Point(int.Parse(position[0]), int.Parse(position[1]));
        gameInstance.addCoin(p, int.Parse(lifeTime));

        Debug.Log("Coin appears at " + p.ToString() + ". It will be there for " + lifeTime.ToString() + " time. Coin value is " + value);
    }
开发者ID:dulajperera,项目名称:Game_Tankers,代码行数:12,代码来源:Resolver.cs

示例14: PrintResultTable

	private string PrintResultTable(ICoordinateSystem fromCoordSys, ICoordinateSystem toCoordSys, Point fromPnt, Point toPnt, Point refPnt, Point backPnt, string header)
	{
		string table = "<table style=\"border: 1px solid #000; margin: 10px;\">";
		table += "<tr><td colspan=\"2\"><h3>" + header + "</h3></td></tr>";
		table += "<tr><td width=\"130px\" valign=\"top\">Input coordsys:</td><td>" + fromCoordSys.WKT + "</td></tr>";
		table += "<tr><td valign=\"top\">Output coordsys:</td><td>" + toCoordSys.WKT + "</td></tr>";
		table += "<tr><td>Input coordinate:</td><td>" + fromPnt.ToString() + "</td></tr>";
		table += "<tr><td>Ouput coordinate:</td><td>" + toPnt.ToString() + "</td></tr>";
		table += "<tr><td>Expected coordinate:</td><td>" + refPnt.ToString() + "</td></tr>";
		table += "<tr><td>Difference:</td><td>" + (refPnt-toPnt).ToString() + "</td></tr>";
		table += "<tr><td>Reverse transform:</td><td>" + backPnt.ToString() + "</td></tr>";
		table += "<tr><td>Difference:</td><td>" + (backPnt - fromPnt).ToString() + "</td></tr>";
		table += "</table>";
		return table;
	}
开发者ID:lishxi,项目名称:_SharpMap,代码行数:15,代码来源:TransformTests.aspx.cs

示例15: TestRoverEncountersObstacleMovingNegatively

        public void TestRoverEncountersObstacleMovingNegatively()
        {
            var obstructionPoint = new Point { X = 2, Y = 2 };
            var planetWithObstacles = new Planet(50, new Point[] { obstructionPoint });
            var rover = new Rover(new Point { X = 3, Y = 2 }, 'W', stateFactory, planetWithObstacles);
            rover.MoveForward();

            Assert.That(rover.IsObstructed, Is.EqualTo(true));
            Assert.That(rover.Obstruction.ToString(), Is.EqualTo(obstructionPoint.ToString()));
            Assert.That(rover.GetCurrentPosition().ToString(), Is.EqualTo("3,2"));
        }
开发者ID:kevPo,项目名称:MarsRover,代码行数:11,代码来源:RoverTests.cs


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