让我给你一个简单的例子来说明我的问题。我似乎无法理解错误:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NetApp.Manage;
namespace Toaster.Library
{
class NetappConnection
{
private string Hostname {get; set;}
private int ApiMajor {get; set;}
private int ApiMinor {get; set;}
private string Username {get; set;}
private string Password {get; set;}
private NaServer NetappServer {get; set;}
public void NetappConnection(string Hostname, int ApiMajor, int ApiMinor, string Username, string Password)
{
this.Hostname = Hostname;
this.ApiMajor = ApiMajor;
this.ApiMinor = ApiMinor;
this.Username = Username;
this.Password = Password;
this.ConnectToNetapp();
}
private void ConnectToNetapp()
{
NaServer s = new NaServer(this.Hostname, this.ApiMajor, this.ApiMinor);
s.ServerType = NaServer.SERVER_TYPE.FILER;
s.TransportType = NaServer.TRANSPORT_TYPE.HTTP;
s.Port = 80;
s.Style = NaServer.AUTH_STYLE.LOGIN_PASSWORD;
s.SetAdminUser(this.Username, this.Password);
this.NetappServer = s; <<-- Error: Ambiguity between 'Toaster.Library.NetappConnection.NetappServer' and 'Toaster.Library.NetappConnection.NetappServer()'
}
public NaServer NetappServer()
{
return this.NetappServer;
}
}
}
老实说,我是一个 C# 新手。但我不明白为什么这是不可能的。是因为我将 o 的引用传递给 this.Variable 吗?
这样做的目标应该是我能够重用 NaServer 对象。