gpt4 book ai didi

C# 私有(private)变量的歧义

转载 作者:太空宇宙 更新时间:2023-11-03 11:16:22 25 4
gpt4 key购买 nike

<分区>

让我举一个简单的例子来说明我的问题。我似乎无法理解错误:

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 对象。

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com