小编Asr*_*n29的帖子

C#foreach在foreach循环中

我对C#没有太多经验,所以如果有人能指出我正确的方向,我会非常感激.我有一个foreach循环引用一个对象的变量.我希望在主要的一个中创建另一个foreach循环,它将当前变量与对象数组中其余变量进行比较(或执行操作).我有以下代码:

// Integrate forces for each body.
    foreach (RigidBodyBase body in doc.Bodies)
    {
        // Don't move background-anchored bodies.
        if (body.anchored) continue;

        // This is where we will add Each Body's gravitational force 
        //  to the total force exerted on the object.

        // For each other body, get it's point and it's mass.

            // Find the gravitational force exterted between target body and looped body.
                // Find distance between bodies.
                    // vector addition
                // Force = G*mass1*mass2/distance^2
            // Find vector of …
Run Code Online (Sandbox Code Playgroud)

c#

11
推荐指数
1
解决办法
2万
查看次数

标签 统计

c# ×1