第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會(huì)有你想問的

C#在foreach循環(huán)中使用點(diǎn)的偏移量方法來修改點(diǎn)的數(shù)組

C#在foreach循環(huán)中使用點(diǎn)的偏移量方法來修改點(diǎn)的數(shù)組

C#
一只萌萌小番薯 2021-05-05 17:21:32
我在理解點(diǎn)的偏移量方法在foreach循環(huán)中如何修改現(xiàn)有點(diǎn)數(shù)組時(shí)遇到麻煩。我可以通過手動(dòng)索引每個(gè)數(shù)組實(shí)體來做到這一點(diǎn),但是我強(qiáng)烈懷疑那不是應(yīng)該怎么做。*編輯要清楚。將偏移點(diǎn)存儲(chǔ)在MyPoints數(shù)組中的最佳方法是什么?請(qǐng)參見下面的代碼。我使用http://rextester.com/在線C#編譯器來測試代碼。using System;using System.Collections.Generic;using System.Linq;using System.Text.RegularExpressions;using System.Drawing;namespace Rextester{    public class Program    {        static int ii = 0;        public static void Main(string[] args)        {            Point[] MyPoints =             {                new Point(0,0),                new Point(10,10),                new Point(20,0)            };            foreach(Point p in MyPoints)            {                p.Offset(5,2); //this works but does not store the new points                             }                  //in MyPoints array when the foreach loop                                //exits, which is what I want.        Console.WriteLine("p1x = {0} \t p1y = {1}", MyPoints[0].X, MyPoints[0].Y);        Console.WriteLine("p2x = {0} \t p2y = {1}", MyPoints[1].X, MyPoints[1].Y);        Console.WriteLine("p3x = {0} \t p3y = {1} \n", MyPoints[2].X, MyPoints[2].Y);        foreach(Point p in MyPoints)        {            MyPoints[ii].Offset(5,2);            ii++;        }        Console.WriteLine("p1x = {0} \t p1y = {1}", MyPoints[0].X, MyPoints[0].Y);        Console.WriteLine("p2x = {0} \t p2y = {1}", MyPoints[1].X, MyPoints[1].Y);        Console.WriteLine("p3x = {0} \t p3y = {1}", MyPoints[2].X, MyPoints[2].Y);        }    }}//This yields the following/*p1x = 0      p1y = 0p2x = 10     p2y = 10p3x = 20     p3y = 0 p1x = 5      p1y = 2p2x = 15     p2y = 12p3x = 25     p3y = 2*/
查看完整描述

1 回答

  • 1 回答
  • 0 關(guān)注
  • 242 瀏覽

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)