字段初始化程序无法引用非静态字段方法或属性Error [英] a field initializer cannot reference the nonstatic field method or property Error
本文介绍了字段初始化程序无法引用非静态字段方法或属性Error的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试使用.Net C#和Azure blob存储
I am trying to work with .Net C# and Azure blob storage
我遵循Microsoft的文档以访问Blob表.
I follow Microsoft's documentation in order to access a blob table.
using Microsoft.WindowsAzure.Storage;
using Microsoft.WindowsAzure.Storage.Table;
using System.Threading.Tasks;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace WebApplication1.Controllers
{
public class EmailAdress
{
CloudStorageAccount storageAccount = new CloudStorageAccount(
new Microsoft.WindowsAzure.Storage.Auth.StorageCredentials(
"experimentstables", "token"), true);
// Create the table client.
CloudTableClient tableClient = storageAccount.CreateCloudTableClient();
// Get a reference to a table named "peopleTable"
CloudTable pexperimentsEmailAddresses = tableClient.GetTableReference("experimentsEmailAddresses");
}
}
在此行
CloudTableClient tableClient = storageAccount.CreateCloudTableClient();
storageAccount被标记为红色,并显示以下错误:
storageAccount is marked red with the following error:
字段初始化器无法引用非静态字段方法或属性
a field initializer cannot reference the nonstatic field method or property
我应该如何解决?
推荐答案
查看全文