小编luc*_*opp的帖子

删除字典c#WPF中的所有条目

我有一个Dictionary存储a的成员,Skilodge我想要一个删除所有成员的方法.目前,它似乎只是删除一个.这是我尝试的方法:

public void DeleteAll()
{
    for (int i = 0; i < Skiers.Count; i = i + 1)
    {
        string iString = i.ToString();
        Skiers.Remove(iString);
    }
}
Run Code Online (Sandbox Code Playgroud)

c# wpf dictionary

3
推荐指数
1
解决办法
156
查看次数

排序字典并获得前3名

我有一本存储"滑雪"锦标赛成员的字典.它还存储得分.我想要做的是能够找到并显示成员的前3个分数.我只是想知道当我陷入困境时,最好的办法是什么.以下是字典以及如何添加成员:

public static Dictionary<string, Skier> Skiers = new Dictionary<string, Skier>();

    static int income;


    string lodgeName;

    public SkiLodge(string newLodgeName)
    {
        newLodgeName = lodgeName;
        Skiers = new Dictionary<string, Skier>();
    }

    static int newNumber = 1;
    //ADD SKIER
    public Skier AddSkier(string inName, string inAddress, int inScore)
    {
        string newNumberString = newNumber.ToString();
        Skier result = new Skier(newNumberString, inName, inAddress, inScore);
        newNumber = newNumber + 1;
        Skier S = new Skier(newNumberString, inName, inAddress, inScore);
        Skiers.Add(newNumberString, S);
        income = income + 100;
        return result;
    }
Run Code Online (Sandbox Code Playgroud)

c# dictionary

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

标准化向量 JavaScript

我目前正在尝试通过我正在做的 2D 图形模块的一些矢量测试。

\n\n

我目前正在努力进行以下测试:

\n\n

标准化函数\xe2\x80\x93 您的 Vector 对象应该有一个 \xe2\x80\x98normalise\xe2\x80\x99 函数,该函数不带参数。该函数应返回一个新构造的 Vector 对象,该对象是 \n标准化 \xe2\x80\x98this\xe2\x80\x99 Vector 的结果(从中生成单位 Vector)。

\n\n

这是我到目前为止所做的:

\n\n

标准化函数 \xe2\x80\x93 您的 Vector 对象应该有一个 \xe2\x80\x98normalise\xe2\x80\x99 函数,该函数不带参数。该函数应返回一个新构造的 Vector 对象,该对象是 \n标准化 \xe2\x80\x98this\xe2\x80\x99 Vector 的结果(从中生成单位 Vector)。

\n\n
 var Vector = (function () {\nfunction Vector(pX, pY, pZ) {\n    this.setX(pX);\n    this.setY(pY);\n    this.setZ(pZ);\n\n}\nVector.prototype.getX = function () {\n    return this.mX;\n};\nVector.prototype.setX = function (pX) {\n    this.mX = pX;\n};\nVector.prototype.getY = function () {\n    return this.mY;\n};\nVector.prototype.setY = function (pY) {\n    this.mY = pY;\n}\nVector.prototype.getZ = function () …
Run Code Online (Sandbox Code Playgroud)

javascript vector

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

保存到现有文本文件c#的结尾

我编写了以下代码,因为我想以列表的形式将字符串保存到文本文件的末尾.

但是,在我尝试保存某些内容时,它会删除文件中的所有先前文本,并添加最新文本.以下是我的代码:

using (var writer = new StreamWriter(@"C:\Users\Falconex\Documents\Visual Studio 2015\Projects\Test2\Test2\bin\Debug\Product.txt"))
{
    writer.WriteLine(productTextBox.Text + Environment.NewLine);
    writer.Close();
}
Run Code Online (Sandbox Code Playgroud)

先谢谢你,露西

c# save streamwriter

1
推荐指数
1
解决办法
945
查看次数

标签 统计

c# ×3

dictionary ×2

javascript ×1

save ×1

streamwriter ×1

vector ×1

wpf ×1