我正在尝试从另一个 cs 文件中调用一个方法。我创建了该方法所在的类的新实例,但出现此错误:
“SteamKit2.SteamFriends”类型没有定义构造函数
谁能帮我理解为什么会这样?
我试图从中调用此方法的类如下
using System;
using SteamKit2;
using SteamTrade;
using System.Collections.Generic;
using SteamBot;
namespace SteamBot
{
public class HarvesterHandler : UserHandler
{
public int FriendCount = 0;
public int FriendToTrade = 0;
SteamFriends me = new SteamFriends();
public override void OnLoginCompleted()
{
FriendCount = me.GetFriendCount();
if (FriendToTrade < FriendCount)
{
Bot.SteamTrade.Trade(me.GetFriendByIndex(FriendToTrade));
Log.Info("Sending Trade Request to Friend " + FriendToTrade + " of " + FriendCount);
return;
}
while (true)
{
Log.Warn("Finished trading");
}
}
}
}
引用的类如下(在单独的cs文件中)
using System.Collections.Generic;
using System.Linq;
using System.Text;
using SteamKit2.Internal;
namespace SteamKit2
{
public sealed partial class SteamFriends : ClientMsgHandler
{
object listLock = new object();
List<SteamID> friendList;
List<SteamID> clanList;
AccountCache cache;
internal SteamFriends()
{
friendList = new List<SteamID>();
clanList = new List<SteamID>();
cache = new AccountCache();
}
public int GetFriendCount()
{
lock ( listLock )
{
return friendList.Count;
}
}
public SteamID GetFriendByIndex( int index )
{
lock ( listLock )
{
if ( index < 0 || index >= friendList.Count )
return 0;
return friendList[ index ];
}
}
}
}