Monotouch: how do I get addressability to this method?
I have two methods in different .cs files. When trying to access DisplayReport (which lives in file #1) from file #2, I am getting the following error:
Error CS0120: An object reference is required to access non-static member `Prager.AppDelegate.DisplayReport()'
This code is in file #1:
public partial class AppDelegate
{
public static string html;
public void DisplayReport() {
if(selectedSiteID == null) {
errorAlert ea = new errorAlert();
In file #2, I have this code:
private void SendViaEmail() {
byte[] d开发者_如何学编程ata = File.ReadAllBytes(filePath);
NSData datas = NSData.FromArray(data);
string[] receipients = {txtEmailAddress.Text};
if (MFMailComposeViewController.CanSendMail) {
_mail = new MFMailComposeViewController();
if(html != null)
_mail.SetMessageBody(html,true); // indicate the body is html
else {
AppDelegate.DisplayReport(); // <--error here
}
Your DisplayReport method needs to be static to be accessed that way:
public static void DisplayReport() {}
精彩评论