1

首先,我只是在学习 C#,所以我在这里有点不了解

using EveAI.Live;
using EveAI.Live.Character;

public CharacterSheet CharSheet(string API, int KEY, int USER)
    {
        string Charsname = null;
        CharacterSheet CharSheet = new CharacterSheet();
        EveApi api = new EveApi(KEY, API, USER);
        CharacterSheet csname = api.GetCharacterSheet();
        Charsname = csname.Name;
        return Charsname;
    }

VS 为“return Charsname;”行抛出错误。

提前致谢

4

1 回答 1

0

CharacterSheet当您返回csname.Namewhich 是一个字符串时,您的方法是期待的。

我怀疑您要么想更改方法以返回 astring而不是CharacterSheet. 或返回csname而不是csname.Name.

public string CharSheet(string API, int KEY, int USER)
{
    string Charsname = null;
    CharacterSheet CharSheet = new CharacterSheet();
    EveApi api = new EveApi(KEY, API, USER);
    CharacterSheet csname = api.GetCharacterSheet();
    Charsname = csname.Name;
    return Charsname;
}

或者

public CharacterSheet CharSheet(string API, int KEY, int USER)
{
    CharacterSheet CharSheet = new CharacterSheet();
    EveApi api = new EveApi(KEY, API, USER);
    CharacterSheet csname = api.GetCharacterSheet();
    return csname;
}
于 2013-08-06T05:35:54.850 回答