I wonder if anyone could help me with this. I'm getting an error saying "The name 'client' does not exist in the current context
". This is in reference to the line var tradePileResponse = await client.GetTradePileAsync();
now I know why it's occuring but I'm not sure how to fix it.
I'm initializing client with var client = new FutClient();
but I can't seem to use it across all of my app.
How can I make this instance available throughout my app? Do I need to create the new instance somewhere else? I tried calling it just after the class but it complained that "The contextual keyword 'var' may only appear within a local variable declaration
"
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
public async void button1_Click(object sender, EventArgs e)
{
var client = new FutClient();
var loginDetails = new LoginDetails(email, password, secret, platform);
try
{
var loginResponse = await client.LoginAsync(loginDetails);
var creditsResponse = await client.GetCreditsAsync();
label1.Text = creditsResponse.Credits.ToString();
}
catch (Exception ex)
{
this.textBox4.Text = ex.Message;
//throw;
}
}
private async void butGetTradepile_Click(object sender, EventArgs e)
{
//var client = new FutClient();
var tradePileResponse = await client.GetTradePileAsync();
Console.WriteLine(tradePileResponse);
}